Handlebars.js oferă șabloane semantice clare fără logică amestecată, extinzând șabloanele Mustache.
Expresii și funcții ajutătoare integrate
<p>{{firstname}} {{lastname}}</p>
<p>{{{rawHtmlContent}}}</p>
{{#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}}
Funcții ajutătoare personalizate
Handlebars.registerHelper('fullName', function (person) {
return person.firstName + ' ' + person.lastName;
});
<p>{{fullName user}}</p>