meteor.js模板助手作为变量vs键+值

时间:2013-12-03 21:47:39

标签: javascript meteor handlebars.js meteorite

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

VS

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

前者工作(Template.hello.loggedin在控制台中打印出函数,添加括号返回的东西),后者没有(给出undefined)。

我认为这些是等价的?

1 个答案:

答案 0 :(得分:2)

除了您找到的情况外,它们是等效的。 github上存在一个未解决的问题:https://github.com/meteor/meteor/issues/886

如果您想致电Template.hello.loggedin(),请使用前者。

相关问题