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="/api/flow.js?q=https%3A%2F%2Fcodereview.stackexchange.com%2Fquestions%2F2953%2F'%2520%2B%2520item.profile_image_url%2520%2B%2520'" alt="' + item.from_user + '" width="56">'
+ '</td>'
+ '<td>'
+ '<section>'
+ '<header>'
+ '<h1><a href="/api/flow.js?q=http%3A%2F%2Ftwitter.com%2F'%0A%2B%20(function(from_user)%20%7B%20%0A%20%20%20%20return%20from_user%20%2B%20'">' + from_user + '</a></h1>';
})(item.from_user)
+ '</header>'
+ '<article>' + item.text.twitterify() + '</article>'
+ '</section>'
+ '</td>'
+ '</tr>'
+ '</table>'
+ '<footer><a href="/api/flow.js?q=http%3A%2F%2Ftwitter.com%2F'%20%2B%20item.from_user%20%2B%20'%2Fstatus%2F'%20%2B%20item.id.toString()%20%2B%20'" target="_blank">' + item.created_at + '</a></footer>'
+ '</div>';
How would I go about to improve this?