访问模板的父订阅状态
Access template's parent subscriptions state
我从 Meteor doc 知道我可以通过编写
来评估模板的订阅状态
{{#if Template.subscriptionsReady}}
<!-- subscriptions ready -->
{{else}}
<!-- loading -->
{{/if}}
如果想访问模板的父状态怎么办?
我想写点像
{{#if Template.parent.subscriptionsReady}}
<!-- parent's subscriptions ready -->
{{else}}
<!-- loading -->
{{/if}}
我最终使用了 meteor-template-extension 包。
我创建了一个助手:
Template.myTpl.helpers({
parentSubscriptionsReady: function () {
return Template.instance().parent(1).subscriptionsReady();
}
});
我是这样使用它的:
{{#if parentSubscriptionsReady}}
<!-- parent's subscriptions ready -->
{{else}}
<!-- loading -->
{{/if}}
当然可以使用 Template.registerHelper
将助手定义为全局助手
我从 Meteor doc 知道我可以通过编写
来评估模板的订阅状态{{#if Template.subscriptionsReady}}
<!-- subscriptions ready -->
{{else}}
<!-- loading -->
{{/if}}
如果想访问模板的父状态怎么办? 我想写点像
{{#if Template.parent.subscriptionsReady}}
<!-- parent's subscriptions ready -->
{{else}}
<!-- loading -->
{{/if}}
我最终使用了 meteor-template-extension 包。
我创建了一个助手:
Template.myTpl.helpers({
parentSubscriptionsReady: function () {
return Template.instance().parent(1).subscriptionsReady();
}
});
我是这样使用它的:
{{#if parentSubscriptionsReady}}
<!-- parent's subscriptions ready -->
{{else}}
<!-- loading -->
{{/if}}
当然可以使用 Template.registerHelper