Closed ai10 closed 11 years ago
The best way to deal with your problem (that you want to have the same helpers on multiple templates) would probably be to do something like this:
var helpers = {
helpMe: function() {
return 'help';
}
};
Template.question.helpers(helpers);
Template.question_phone.helpers(helpers);
Template.question_tablet.helpers(helpers);
Or, if you wanted to have a slightly different helper set on tablets for example you could do something like this:
var helpers = {
helpMe: function() {
return 'help';
}
};
Template.question.helpers(helpers);
Template.question_phone.helpers(helpers);
Template.question_tablet.helpers(_.extend({
helpMeTablet: function() {
return 'help from your tablet';
}
}, helpers));
That should copy the properties from the helpers object into the new object and pass it to Template.question_tablet.helpers().
I would not overwrite the template object with another template's object. I've never done it, but I can imagine that it wouldn't work at all. If I had to guess, it would replace both question_phone and question_tablet with question, which I don't think is what you want to do.
Is there a potential problem with this approach
Or should we do