I have a helper function that looks like this:
hbs.registerHelper('feature', function(request, flag, options) { if (features(flag, request)) { return options.fn(this); } else if (options.inverse) { return options.inverse(this); } });
And used in the template again and again:
{{feature request "some-feature"}} ... {{/feature}}
I would like to remove the request part in the template, since it always has the same value and never changes. Therefore, I assume that I could bind request to feature when rendering, and obviously this changes every time, and I don't want it to spill onto another request.
Something like:
res.render("page", { feature: hbs.helper.feature.bind(null, req) });
Is it possible?
Remy Sharp
source share