Json 把手js,获取特定对象数组并循环通过

Json 把手js,获取特定对象数组并循环通过,json,if-statement,handlebars.js,Json,If Statement,Handlebars.js,我试图从一个数组生成两个表 "tables": [ { "tableName": "table1", "dataRow": ["name": "test858"] }, { "tableName": "table2", "anotherRow": ["name": "test123"] } ] 我试过这么做 {{#each tables}} <table> <thead> &

我试图从一个数组生成两个表

"tables": [
{
"tableName": "table1",
"dataRow": ["name": "test858"]
},
{
"tableName": "table2",
"anotherRow": ["name": "test123"]
}
]
我试过这么做

{{#each tables}}
            <table>
                <thead>
                    <tr>
                        <th>{{tableName}}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        {{#if dataRow}}
                        <td>test1</td>
                        {{else}}
                        <td>test2</td>
                        {{/if}}
                    </tr>
                </tbody>
            </table>
 {{/each}} 
{{#每个表}
{{tableName}}
{{#如果数据行}
测试1
{{else}
测试2
{{/if}
{{/每个}}
这将打印两个表名和“test2”

如何循环两个阵列?

工作示例:

模板:

<script id="entry-template" type="text/x-handlebars-template">
{{#each this}}
            <table>
                <thead>
                    <tr>
                        <th>{{tableName}}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        {{#if dataRow}}
                        <td>test1</td>
                        {{else}}
                        <td>test2</td>
                        {{/if}}
                    </tr>
                </tbody>
            </table>
 {{/each}}  
</script>
<div id="data">
</div>

{{{#每个这个}
{{tableName}}
{{#如果数据行}
测试1
{{else}
测试2
{{/if}
{{/每个}}
<script id="entry-template" type="text/x-handlebars-template">
{{#each this}}
            <table>
                <thead>
                    <tr>
                        <th>{{tableName}}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        {{#if dataRow}}
                        <td>test1</td>
                        {{else}}
                        <td>test2</td>
                        {{/if}}
                    </tr>
                </tbody>
            </table>
 {{/each}}  
</script>
<div id="data">
</div>