Handlebars.js provides semantic templating without logic entanglements, extending Mustache templates.
Syntax & Helpers
Expressions & Interpolation
<p>{{firstname}} {{lastname}}</p>
<p>{{{rawHtmlContent}}}</p>
Built-in Block Helpers
{{#if isActive}}
<span class="active">Active</span>
{{else}}
<span class="inactive">Inactive</span>
{{/if}}
{{#each items}}
<li>{{this}}</li>
{{/each}}
{{#with author}}
<h2>By {{name}}</h2>
{{/with}}
Custom Helpers
Handlebars.registerHelper('fullName', function (person) {
return person.firstName + ' ' + person.lastName;
});
Template usage:
<p>{{fullName user}}</p>