I need to distinguish how the helper is being called, for example following 2 cases
{{#myHelper data}}{{myHelperResponse}}{{/myHelper}}
{{myHelper data}}
Within the Javascript helper method, is it possible to distinguish between these 2 calls.
Checking the last argument options. When calling an helper method with opening and closing mustaches, there are 2 methods available options.fn and options.inverse, such as:
Handlebars.registerHelper('myHelper', function() {
const options = arguments[arguments.length - 1];
return options.fn ? options.fn('TRUE') : 'FALSE';
});
{{#myHelper}}{{this}}{{/myHelper}} // This outputs TRUE
{{myHelper}} // This outputs FALSE