Javascript – HTML generation in JS code


I'd like to know your thoughts about HTML code generation in my JS code.

I just think that the html.push("<tag>" + something + "</tag>") style pretty annoying.
I've already tried something with templates inside my HTML file (and put some placeholders therein), and then used its content to a replace the placeholders to my real values.

But maybe you guys have other ideas, possibly one using jQuery.

Best Solution

jQuery has javascript template plugins like jBind and jTemplate. I haven't used them myself but I do recommend jQuery whenever possible.

A note on html generation, it is not searchable by search engines in most cases.