hbs.registerHelper(`iff`, function (a, operator, b, opts) {
let bool = false;
a.toString();
b.toString();
switch (operator) {
case `===`:
bool = a === b;
break;
case `>`:
bool = a > b;
break;
case `<`:
bool = a < b;
break;
default:
bool = a === b;
}
if (bool) {
return opts.fn(this);
}
return opts.inverse(this);
});
{{#iff value1 '>' value2}}
do the thing
{{/iff}}
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