Function to render HTML from template and data.
Pass an object data to $.fn.render() to render the html. This returns jQuery object which contains the rendered nodes.
<div id="output"></div>
<script type="text/template" id="template-foo">
<div>
<span class="name">{{name}}</span>
<span class="age">{{age}}</span>
</div>
</script>
$("#template-foo").render({name: "John", age: 20})
.appendTo("#output");
Pass an array to loop.
$("#template-foo").render([
{name: "John", age: 20},
{name: "Tom", age: 23},
...
]);
Pass false
as the second argument to get the HTML string.
var html = $("#template-foo").render({...}, false);