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
In Handlebars, the parenthesis are used to invoke the first item listed as a function, using (optional) subsequent items as parameters. So, the syntax from Ember CAN be used without Ember, provided you can set the context yourself. For example:
context.eq = function(param1, param2) {
return param1 === param2;
}
context.notEq = function(param1, param2) {
return param1 !== param2;
}
Once you do that, you can use the standard {{#if}} and {{#unless}} block operations:
{{#if (eq someVar "someValue") }}
Be careful of switching contexts with {{with}} or when using inline partials. You can lose track of your defined "eq" function. The guaranteed way to work, regardless of new contexts:
{{#if (@root.eq someVar "someValue") }}