Question

I find myself doing this a lot:

{{> eventTitle}}

<template name="eventTitle">
    {{eventTitle}}
</template>

Is there a way to cut out the template and just do:

{{eventTitle}}

Then in the js file:

Template.eventTitle.eventTitle = function () {
    return "Title!";
};
Était-ce utile?

La solution

You can use Handlebars.registerHelper just like this :

Handlebars.registerHelper("eventTitle",function(){
    return "Title!";
});

Autres conseils

In Meteor 1.0 use Template.registerHelper(name,function) to register a global template helper.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top