HandlebarsJS doesn't support string equality ('==') so I have to write my own helper, but this answer isn't clear:
https://stackoverflow.com/a/15095019/1005607
Handlebars.registerHelper('if_eq', function(a, b, opts) {
if(a == b) // Or === depending on your needs
return opts.fn(this);
else
return opts.inverse(this);
});
and then adjust your template:
{{#if_eq this "some message"}}
...
{{else}}
...
{{/if_eq}}
1) Why is he doing {{#if_eq ..}}
rather than {{#if if_eq .. }}
?
2) I also need to do ELSE-IF, which is supported since Handlebars 3.0.0 (I have 4.0). But using his notation, I wouldn't be able to do {{#elseif_eq}}
there is no such expression. How would I implement an ELSE-IF with this custom helper?