Handlebars.js first script - Hello World template
Handlebars.js is a Javascript template engine.
The content in the box below is generated by a Handlebars template:
Complete source code:
<script src="jquery.min.js"></script>
<script src="handlebars-1.0.0.beta.6.js"></script>
<span id="content-placeholder" class="text_js"></span>
<script id="template_1" type="text/x-handlebars-template">
<div style="border: 1px solid black; width: 350px">
<i>{{hello_world}}</i><br>
{{test_var}}
</div>
</script>
<script>
var source = $("#template_1").html();
var template = Handlebars.compile(source);
var context = {hello_world: "Hello world!", test_var: "Content generated using Handlebars.js template."};
var html = template(context);
$("#content-placeholder").html(html);
</script>
More about Handlebars.js