{
letters: ['a', 'b', 'c'],
numbers: ['1', '2', '3']
}
我怎么会产生
a1
a2
a3
b1
b2
b3
c1
c2
c3
从本质上说,
{{#each letters}}
{{#each ../numbers}}
what to put here?
{{/each}}
{{/each}}
我特别使用https://github.com/sunng87/handlebars-rust,然而这在理论上已经非常接近功能奇偶性,所以在handlebars.js中应该如何兼容。
作为参考,我的实际用例是C++代码生成。这个问题主要是关于访问这个内部循环的this
。现在我的代码看起来像
{{#each variant}}
{{#each ../typearg}}{{#if @first}}template <{{/if}}{{this}}{{#if @last}}>{{else}},{{/if}}{{/each}}
{{/each}}
但是出于某种原因,这个输出
template <>
template <>
时,我期待它输出
template <T>
template <T>
的对象是相关的,被传递到它的形式是
{
typearg: [ 'T' ],
variant: [{ }, { }]
}
看起来像一个嵌套的'#each'循环,外面有'letters'就可以了。 –
有没有办法做到维持嵌套构造? –
请将'handlebars-rust'添加为标签,尤其是在您根据此问题创建错误报告时。 –