A good start : https://github.com/janl/mustache.js
Another nice one http://handlebarsjs.com/ or http://underscorejs.org/
Templates comparison :
Question
I need a good simple template engine for HTML
on JS
. I'm looking for a third-party library like jQuery. Or maybe within jQuery already exists any temlate engine? Can advise something?
Solution
A good start : https://github.com/janl/mustache.js
Another nice one http://handlebarsjs.com/ or http://underscorejs.org/
Templates comparison :
OTHER TIPS
The simplest one is included in underscore.js or lodash.js It works like this
var list = "<% _.each(people, function(name) { %> <li><%= name %></li> <% }); %>";
_.template(list, {people: ['moe', 'curly', 'larry']});
// => "<li>moe</li><li>curly</li><li>larry</li>"
Apart from templating, underscore is also a great JS utility belt.
Handlebars and Mustache are a bit more complex and allow to build more sophisticated templates.