I would like to create a handlebars template and use a local helper for just that single template. I know how to use Handlebars.registerHelper to register helpers for all templates, but I only need this for the local template. (something similar to what ExtJS supports with XTemplates)
For example something like this based upon handlebars.js documentation:
var context = { posts: [{url: "/hello-world", body: "Hello World!"}] };
var source = "<ul>{{#posts}}<li>{{{link_to this}}}</li>{{/posts}}</ul>"
var template = Handlebars.compile(source, {
link_to: function(context) {
return "<a href='" + context.url + "'>" + context.body + "</a>";
}
);
template(context);
Is this possible or do all helpers have to be registered globally?
Use this syntax:
Local helpers redefine global. So if you want
each,ifor other registered global helpers just extend object: