更新时间:2023-01-08 15:32:41
示例中存在语法错误。正确的语法是 {{@ .. / index}}
。
我们正在寻找可以在未来版本的语言中支持这些参数的自定义命名,因此更易于处理。
https://github.com/wycats/handlebars.js/issues/907
How to access parent @index value in each-loop?
Tried the following:
{{#each company}}
{{#each employee}}
{{../@index}} // how to access company index here?
{{/each}}
{{/each}}
This results to an error:
Expecting 'ID', got 'DATA'
There is a syntax error in the example. The correct syntax is {{@../index}}
.
We are looking at ways that we can support custom naming of these parameters in future versions of the language so this is easier to deal with. https://github.com/wycats/handlebars.js/issues/907