访问模板的父订阅状态

时间:2015-09-26 19:50:20

标签: meteor meteor-blaze

我从Meteor doc知道我可以通过编写

来评估模板的订阅状态
{{#if Template.subscriptionsReady}}
  <!-- subscriptions ready -->
{{else}}
  <!-- loading -->
{{/if}}

如果想要访问模板的父状态怎么办? 我想写点像

{{#if Template.parent.subscriptionsReady}}
  <!-- parent's subscriptions ready -->
{{else}}
  <!-- loading -->
{{/if}}

1 个答案:

答案 0 :(得分:0)

我最终使用了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

将帮助程序定义为全局帮助程序
相关问题