We need to get rid of Template.X.X


#1

Why must I type/copy Template every time I want a new helper or event?

Template.main.helpers
Template.main.events
Template.home.helpers
Template.home.events

It should be What do we want and what we want to do it with. Is the logical syntax.

events.Template({
//do something
})

So much repetition and ugliness for one file.


#2

What would the solution be in your opinion?

Current implemenatation:
Template - keyword that covers all of the templates
templateName - refers to the needed template
events/helpers/onCreated etc. - data specific to the template

Your implementation:
events/onCreated/onDestroyed etc
templateName

Youre hogging a bunch of global variables with little benefit. Ends up being pretty similar syntax IMO, you’re just removing Template from it, which is actually pretty useful there in the front.


#3

Somewhere global do var T = Template.

Then T.main.events should work :smile:


#4

The current implementation seems disjointed. I would have preferred something like:

Template.main({
  onCreated: function() {
  },
  helpers: {
  },
  events: {
  }
})

But then again, I have one js file per template so it’s not that big of a deal to me.


#5

That syntax could be easily added by a package, I’d encourage you to write one and post it here.