Okay, I understand that mustache cannot keep track of index
of array and it needs everything in hash
.
So, I am using following technique, it works but little bit ugly.
function prepareForMustache ($arr) {
foreach($arr as $k => &$v) {
$v['key'] = $k;
$v['pagesCount'] = count($v['pages']);
}
}
$arr = prepareForMustache($arr);
$tpl->render(array(
'arr' => new ArrayIterator($arr)
));
And consuming in mustache template as,
{{#arr}}
{{width}}
{{key}}
{{pagesCount}}
{{/arr}}