سؤال

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