I am terrible with writing JavaScript code that outputs HTML. So, here's how a string literal looks like in a project that I'm working on:
tweet = '<div class="h-ui-box">'
+ '<table>'
+ '<tr>'
+ '<td id="first">'
+ '<img src="' + item.profile_image_url + '" alt="' + item.from_user + '" width="56">'
+ '</td>'
+ '<td>'
+ '<section>'
+ '<header>'
+ '<h1><a href="http://twitter.com/'
+ (function(from_user) {
return from_user + '">' + from_user + '</a></h1>';
})(item.from_user)
+ '</header>'
+ '<article>' + item.text.twitterify() + '</article>'
+ '</section>'
+ '</td>'
+ '</tr>'
+ '</table>'
+ '<footer><a href="http://twitter.com/' + item.from_user + '/status/' + item.id.toString() + '" target="_blank">' + item.created_at + '</a></footer>'
+ '</div>';
How would I go about to improve this?