Closed utillity closed 3 years ago
just found out they are called block-helpers: https://handlebarsjs.com/guide/block-helpers.html#basic-blocks. Is there a way to auto-register these?
ah, never mind. It seems there is the options
property added as the last parameter of the function, so I can implement it as in the examples.
here's my working `equals` block helper:
equals: function(v1, v2, options) {
// options: { name:string, hash:object, data:{ root:object } }
v1 = v1?.toLowerCase() ?? "";
v2 = v2?.toLowerCase() ?? "";
if (v1 == v2) {
return options.fn(this);
} else {
return options.inverse && options.inverse(this) || "";
}
},
I'm trying to emulate the helpers provided by SendGrid, but the preview just renders TRUE or FALSE, instead of interpreting the helper as a condition.
Helper:
Usage: