Sorry if I'm bored, but could you declare the function as an object and assign it to several helpers? For instance:
// Common methods doCommonThing = function(instance) // don't use *var* so that it becomes a global { /* Commonly used method is defined here */ } Template.myTemplate.helpers({ otherThing1: function() { var _instance = this; // assign original instance *this* to local variable for later use /* Do proprietary thing here */ doCommonThing(_instance); // call the common function, while passing in the current template instance }, otherThing2: function() { var _instance = this; /* Do some other proprietary thing here */ doCommonThing(_instance); } });
By the way, if you notice that you constantly duplicate the same helpers across several templates, this may help to use
Template.registerHelper instead of assigning the same function to several places.
source share