eachWith

Merge two or more arrays and iterate over the resulting array of objects or tags.

1
2
3
{{#eachWith [array1] [array2]...}}
{{this}}
{{/eachWith}}
Example
format JSON XML
Data JSON
1
2
3
4
5
6
7
8
9
10
11
12
{
"vegetables": [
{"name": "Tomato"},
{"name": "Cauliflower"},
{"name": "Carrot"}
],
"pricing": [
{"total": "5.20"},
{"total": "6.40"},
{"total": "3.10"}
]
}
Code
1
2
3
{{#eachWith vegetables pricing}}
<div>{{name}}: $ {{total}}</div>
{{/eachWith}}
Result
Data XML
1
2
3
4
5
6
7
8
9
10
11
12
<Food>
<vegetables>
<vegetable name="Tomato" />
<vegetable name="Cauliflower" />
<vegetable name="Carrot" />
</vegetables>
<pricing>
<price total="5.20" />
<price total="6.40" />
<price total="3.10" />
</pricing>
</Food>
HTML
1
2
3
{{#eachWith Food.vegetables Food.pricing}}
<div>{{_name}}: $ {{_total}}</div>
{{/eachWith}}
Result