handlebars: Register `if_equal` handlebar helper.

`if_equal` execute conditional code if both
conditions are equal in templates.
This commit is contained in:
Yashashvi Dave 2019-06-14 18:06:17 +05:30 committed by Tim Abbott
parent 1f5720d1b8
commit 30821dbcbb
1 changed files with 9 additions and 0 deletions

View File

@ -75,6 +75,15 @@ Handlebars.registerHelper('unless_a_not_b', function () {
return options.fn(this); return options.fn(this);
}); });
Handlebars.registerHelper('if_equal', function () {
// Execute conditional code if both values are equal
var options = arguments[arguments.length - 1];
if (arguments[0] === arguments[1]) {
return options.fn(this);
}
return options.inverse(this);
});
Handlebars.registerHelper('if_not_a_or_b_and_not_c', function () { Handlebars.registerHelper('if_not_a_or_b_and_not_c', function () {
var options = arguments[arguments.length - 1]; var options = arguments[arguments.length - 1];
if (arguments[0] === false || arguments[1] === true && arguments[2] === false) { if (arguments[0] === false || arguments[1] === true && arguments[2] === false) {