I am using Mustache and using the data
{ "names": [ {"name":"John"}, {"name":"Mary"} ] }
My mustache template is:
{{#names}}
{{name}}
{{/names}}
What I want to be able to do is to get an index of the current number in the array. Something like:
{{#names}}
{{name}} is {{index}}
{{/names}}
and have it print out
John is 1
Mary is 2
Is it possible to get this with Mustache? or with Handlebars or another extension?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…