{{#result:i}}
<tr>
{{#headers:h}}
<td>{{result[i][this]}}</td>
{{/headers}}
</tr>
{{/result}}
The reason this works is that the <td>
is repeated for each item in the headers
array, because it's inside a headers
section - so far, so obvious. Because of that, we can use this
to refer to the current header (head1
, head2
etc). The trick is to get a reference to the current row - and because you've already created the i
index reference, we can do that easily with result[i]
. Hence result[i][this]
.
Here's a demo fiddle: http://jsfiddle.net/rich_harris/dkQ5Z/