[英]mandrill - handlebars how can i iterate over 2 dimension array?
Say I have this array: 说我有这个数组:
var arr = [
[1,4,6,8,3,9,1],
[2,4,6,7,3,2,7]
];
And I want to iterate over it with mandrill -> handlebar #each how will I do it ? 我想使用mandrill-> handlebar进行迭代#each我将如何做?
so far I have something like 到目前为止,我有类似
{{#each arr}}
{{#each this}}
{{this}}
{{/each}}
{{/each}}
the above will output the desired result but when I add a condition inside the second each this
value changes to an array I assume it takes the parent this - not sure. 上面将输出期望的结果,但是当我在第二个条件内添加一个条件时, this
值将更改为数组,我认为它需要父级-不确定。
{{#each arr}}
{{#each this}}
{{#if @first}}
<div>{{this}} - first</div>
{{else}}
<div>{{this}}</div>
{{/if}}
{{/each}}
{{/each}}
More over when I use normal handlebars it works perfectly fine. 此外,当我使用普通车把时,它的工作原理也很好。 EG http://jsfiddle.net/ccrmwont/2/ EG http://jsfiddle.net/ccrmwont/2/
This is pretty specific issue I know but I am stuck with this for 2 days now. 我知道这是一个非常具体的问题,但是我已经坚持了两天。
you should use the index in your second iteration: 您应该在第二次迭代中使用索引:
{{#each arr}}
{{#each 0}}
{{#if @first}}
<div>{{0.0}} - first element in first array</div>
<div>{{0.1}} - second element in first array</div>
{{/each}}
{{#each 1}}
<div>{{1.0}} -first element in second array</div>
<div>{{1.1}} -second element in second array</div>
{{/each}}
{{/each}}
I dont think Mandrill yet supports full handlebars functionality, this is probably the best way to do this at the moment. 我认为Mandrill还不支持完整的车把功能,这可能是目前最好的方式。 See more here: 在这里查看更多:
https://mandrill.zendesk.com/hc/en-us/articles/205582537-Using-Handlebars-for-dynamic-content https://mandrill.zendesk.com/hc/en-us/articles/205582537-Using-Handlebars-for-dynamic-content
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.