I have a template that looks like this:
<div class="users">
<a class="username">{{ username }}</a>
<br>
<span class="age">{{ age }}</span>
</div>
I have an ajax request that comes in and returns something like this:
[{username: 'bob', age: 12}, {username: 'terry', age: 34} ... ]
I'm looking for a template engine that will just let me do this:
var elments = [];
$.each(ajax_result, function(obj) {
elements.append(SomeTemplateEngine($("#my_template").text(), obj);
}
$("#some_container").append(elements);
Basically, I want to define my template in the HTML as a text node. And When I finish the rendering, I need to place it into the DOM. There are a bunch of javascript template engines out there, which one bets fits my needs?