BorisMoore/jsrender — Issue #56: Access array elements
Author: ThorbenJ
Created: 2011-12-25 13:48:14+00:00
State: open

Hi,

I don't want to iterate over an array, i would like to be able to access specific array elements, but I can't work out how..

Can you help?

e.g.

{
columns: [ 'letter', 'number', 'year' ],
data: [
[ 'A', 1, 2001 ],
[ 'B', 2, 2002 ],
[ 'C', 3, 2003 ],
}

{{#each data}}

Letter: {{=$data[0]}}, Number: {{=$data[1]}}, Year: {{=$data[2]}}

{{/each}}

Here I do almost with every element, but in my actual code values are treated very differently.

The only way I can see, at the moment, is to have another inner each, with lots of: if itemNumber == 0, etc
which would be horrible.

Regrads,

Thorben