【发布时间】:2015-08-11 13:49:40
【问题描述】:
我想将参数传递给我在循环中调用的模板:
<template name="show_people">
<div class="panel-body">
{{#each people}}
<div>
{{>person }}
{{>person doing="running up the hill"}}
</div>
{{/each}}
</div>
</template>
<template name="person">
<h3>{{name}} is {{doing}}</h3>
</template>
助手javascript:
Template.show_people.helpers({
people: function() { return [{ name: 'Jack' },{ name: 'Jill' }]; }
});
在模板中添加 'doing' 参数似乎破坏了循环项的上下文。这是我要返回的内容:
Jack is
is running up the hill
Jill is
is running up the hill
我希望 person 模板能够同时访问参数和上下文。这如何实现?
【问题讨论】: