Meteor 1.2将@Index传递给子模板

时间:2016-01-12 20:38:48

标签: meteor meteor-blaze spacebars

刚开始使用Meteor,所以我可能会遗漏一些基本的东西。在Meteor 1.2中,他们有{{@index}}指令。

如果我有一个模板:

...
{{#each items}}
    {{@index}}
    {{> childTemplate}} 
{{/each}}
...
<template name="childTemplate">
{{@index}}
</template>

主模板中的@index可以使用,但是childTemplate中的@index不会有效。我使用它的工作是调用childTemplate传入{{> childTemplate @index=@index}}

foreach($allmonths as $ind){
 echo '<div class="col-md-4">';
 echo '<table>{{ content here }}</table>';
 echo '</div>';

这是正确的方法吗?还是有更多的东西?

1 个答案:

答案 0 :(得分:4)

是的,没关系

我在这里回答了类似的问题: -

How to get the @index of nested #each in meteor

但在这种情况下传递它是好的。

Meteor有"../var"来到父上下文,但这是模板上下文,而不是每个块,所以我认为没有更多的计量方式

相关问题