在 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'
),
),
));