我一直在试验流星,遇到了一些我无法弄清楚的东西。为了好玩,我试图制作一台老虎机。我有以下的HTML:有没有办法将变量传递到流星模板中?
<div class="slot-wrapper">
{{> slot}}
{{> slot}}
{{> slot}}
</div>
<template name="slot">
<div class="slot">
<div class="number"><span>{{ number }}</span></div>
<div class="divider"></div>
</div>
</template>
我想为每个插槽有不同的数字。是否有可能将变量传递给模板?事情是这样的:
<div class="slot-wrapper">
{{> slot 1}}
{{> slot 2}}
{{> slot 3}}
</div>
<template name="slot">
<div class="slot">
<div class="number"><span>{{ number i}}</span></div>
<div class="divider"></div>
</div>
</template>
也许我想这个错误的方式,有一个更好的办法。
**流星已经改变并引入Spacebars **详情请参阅:https://www.discovermeteor.com/blog/spacebars-secrets-exploring-meteor-new-templating-engine/和Dascalescu回答:http ://stackoverflow.com/a/25090098/220060 – nalply 2014-08-02 13:26:53