// in app.js
hbs.registerHelper(`ifEquals`, function (a, b, opts) {
if (a.toString() === b.toString()) {
return opts.fn(this);
}
return opts.inverse(this);
});
// in hbs template
{{#ifEquals name 'Foo'}}
true
{{else}}
false
{{/ifEquals}}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter