Handlebars.js - 从2D数组访问父索引

use*_*212 5 arrays indexing each this handlebars.js

我在JSON对象中有一个2D数组(称为table;)

data = {

tableID : "testTable",

table : [
[{type:'a', value:'x'},{type:'a', value:'y'},{type:'a', value:'z'}],
[{type:'a', value:'x'},{type:'a', value:'y'},{type:'a', value:'z'}],
[{type:'a', value:'x'},{type:'a', value:'y'},{type:'a', value:'z'}]
]

};
Run Code Online (Sandbox Code Playgroud)

并且已经使用模板成功地使用把手渲染它:

<table id = "{{tableID}}-table">

{{#each table}}

    <tr id = "{{../tableID}}-row-{{@index}}">

        {{#each this}}

            <td id = "{{../../tableID}}-row-{{../index}}-col-{{@index}}">

                {{this.type}}-{{this.value}}

            </td>

        {{/each}}

    </tr>

{{/each}}

</table>
Run Code Online (Sandbox Code Playgroud)

但是,在td标记id中,我似乎无法访问父索引{{../index}} - 行的索引.什么都没有返回:

<td id = "testTable-row--col-x">
Run Code Online (Sandbox Code Playgroud)

但是,我可以访问当前上下文的索引{{@index}}.

有任何想法吗??

很多人提前感谢!!

丰富

ps使用1.0.0-rc.3

Vin*_*are 2

这是车把上的一个悬而未决的问题/功能。您可以在此处查看相同的进度

不过您可以在此处查看解决方法