在子节中,Mustache可以从父节读取变量吗?
比如我下面的例子,我想要的 {{order_store.id}} 从它的父级读取变量 $ order_store [(当前子循环的数组索引)] ['id']
template.mustache
{{#order_store}}<table>
<caption>
Store Name: {{name}}
Product Ordered: {{products}}
Product Weights: {{products_weight}}
</caption>
<tbody>
{{#shipping_method}}<tr>
<td>
<input type="radio" name="shipping[{{order_store.id}}]" id="shipping-{{id}}" value="{{id}}" />
<label for="shipping-{{id}}">{{name}}</label>
</td>
<td>{{description}}</td>
<td>{{price}}</td>
</tr>{{/shipping_method}}
</tbody>
</table>{{/order_store}}
样本数据(以PHP为单位);
$order_store => array(
array(
'id' => 1,
'name' => 'Kyriena Cookies',
'shipping_method' => array(
array(
'id' => 1,
'name' => 'Poslaju',
'description' => 'Poslaju courier'
),
array(
'id' => 2,
'name' => 'SkyNET',
'description' => 'Skynet courier'
),
),
));