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!";
};
有帮助吗?

解决方案

You can use Handlebars.registerHelper just like this :

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

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top