Could I use chainable method on Template.x.helpers().events


#1

Could I use chainable method on Template.x.helpers().events…?

Template.nyTemplate.helpers({
...
})
.events({
})
....
...

#2

You could perhaps wire it up using underscore chain and mixins.

But helpers and events are two very different things, so why would you want that?


#3

Because i don’t write duplicate

Template.nyTemplate.helpers();

Template.nyTemplate.events();

Template.nyTemplate.onRendered();

#4

If by duplicates, you mean template inheritance, you can take a look at https://atmospherejs.com/aldeed/template-extension otherwise, I don’t quite understand what you’d actually achieve with chaining since chaning is a construct that allows passing function I/O through a predefined path of functions, in which helpers, events and the onRendered callbacks do not seem to share any common I/O except for the template instance, which itself is already available to each of them separately.


#5

Not an answer to your question, but I usually write it as this:

var T = Template.nyTemplate

T.helpers();

T.events();

T.onRendered();

And I call the functions in the same order as Meteor will (for example onRendered before events).


[SOLVED] Template name as variable
#6

Kudos! You my hero :smile: