How to generate HTML using JSON in an elegant way in jQuery?
2012-07-17 10:48:06 +08:00
GordianZ
Currently I'm using an HTML template, and using selectors to fill in those data like this:
$("#post-title > a").text(data.title); $.each(doc.comments, function(index, comment) { // some raw HTML tangled up in JavaScript... });
It's really repetitive and rely too much on tags' ID attribute. Is there a way to separate HTML tags from JavaScript? I've heard jQuery Templates, but they're deprecated aren't they?