我找到了this,我正在尝试这个:
for _notice in ['created', 'edited']
((notice) ->
Template.test[notice] = ->
console.log notice
Session.get notice
)(_notice)
但是在控制台中我得到了created
两次,还有:
> Template.test.edited
> function () {
console.log(notice);
return Session.get(notice);
}
我想我想在功能上看到edited
,我怎么能这样做?或者如何使用for循环定义这些函数?