2015-09-26 101 views
2

我从Meteor doc知道我可以写Access模板的父母订阅状态

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

如果想访问该模板的父状态什么评估模板的订阅状态? 我想写点东西像

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

回答

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

一个全球性