allidoiswin
allidoiswin

Reputation: 2589

meteor.js Template helpers as variable vs key+value

Template.hello.loggedin = function() { return something }

vs.

Template.hello.helpers({
  'loggedin': function () { return something }
})

The former works (Template.hello.loggedin prints out the function in the console, adding parenthesis returns the something), the latter doesn't (gives undefined).

I thought these were equivalent??

Upvotes: 3

Views: 244

Answers (1)

Tarang
Tarang

Reputation: 75985

They are equivalent except in the case you found. There is an open issue on github about this: https://github.com/meteor/meteor/issues/886.

If you want to call Template.hello.loggedin() use the former.

Upvotes: 2

Related Questions