يوفر Handlebars.js قوالب دلالية واضحة دون تشابك المنطق، ممتداً من قوالب Mustache الشهيرة.
التعبيرات ومساعدات الكتل المضمنة
<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}}
المساعدات المخصصة (Custom Helpers)
Handlebars.registerHelper('fullName', function (person) {
return person.firstName + ' ' + person.lastName;
});
<p>{{fullName user}}</p>