Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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??

like image 519
allidoiswin Avatar asked Jun 07 '26 04:06

allidoiswin


1 Answers

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.

like image 192
Tarang Avatar answered Jun 08 '26 17:06

Tarang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!