Is it possible in Handlebars to check if a string is equal to another value without registering a helper? I can\'t seem to find anything relevant to this in the Handlebars r
I would just use helpers like this:
Handlebars.registerHelper('ifeq', function (a, b, options) {
if (a == b) { return options.fn(this); }
return options.inverse(this);
});
Handlebars.registerHelper('ifnoteq', function (a, b, options) {
if (a != b) { return options.fn(this); }
return options.inverse(this);
});
Then in your code:
{{#ifeq variable "string"}}
... do this ...
{{/ifeq}}
{{#ifnoteq variable "string"}}
... do this ...
{{/ifnoteq}}