【发布时间】:2014-08-04 19:42:08
【问题描述】:
Meteor 空格键有没有办法存储模板函数的返回值? 我会解释得更好。
例如,假设我需要知道某个事件是否已启动。 在 client.js 上,我将拥有:
Template.event.isEventStarted = function(eventId) {
var event = Events.findOne({_id: eventId});
return Events.isStarted(event);
}
假设现在我需要从“事件”模板多次访问“isEventStarted”。我还需要从子模板访问它。显然,每次调用“isEventStarted”时都会执行查询,函数“isStarted”也是如此。他们执行客户端,但我可能有许多带有许多子模板的事件模板。
【问题讨论】:
标签: function templates variables meteor spacebars