Html 组装(模板):从嵌套的每个块中获取父值
从父循环/每个循环获取值时出现问题。我该怎么做 我在循环一些问题,然后循环一些答案。在每个答案上,我想添加问题ID JSON:Html 组装(模板):从嵌套的每个块中获取父值,html,handlebars.js,assemble,grunt-assemble,Html,Handlebars.js,Assemble,Grunt Assemble,从父循环/每个循环获取值时出现问题。我该怎么做 我在循环一些问题,然后循环一些答案。在每个答案上,我想添加问题ID JSON: { "questions": [ { "id": 1, "answers": [ ... ... ... ] } ] } 和assembly.io嵌套循
{
"questions": [
{
"id": 1,
"answers": [
...
...
...
]
}
]
}
和assembly.io嵌套循环/each
{{#forEach questions}}
<h2>{{id}}</h2>
<ul>
{{#forEach this.answers}}
<li>
<input type="radio" name="{{id}}" id="{{id}}-{{index}}"/>
</li>
{{/forEach}}
</ul>
{{/forEach}}
{{{#forEach questions}
{{id}
{{{#关于这个,回答}
-
{{/forEach}}
{{/forEach}}
您知道如何从父循环/每个循环获取ID吗
提前谢谢…:-) 在把手中,您可以使用
{{{#forEach questions}
{{id}
{{{#关于这个,回答}
-
{{/forEach}}
{{/forEach}}
太棒了!真不敢相信我没找到。非常感谢。
{{#forEach questions}}
<h2>{{id}}</h2>
<ul>
{{#forEach this.answers}}
<li>
<input type="radio" name="{{../id}}" id="{{../id}}-{{index}}"/>
</li>
{{/forEach}}
</ul>
{{/forEach}}