In mustache if we have an array like :
var a = [1,2,3,4];
We can create template like:
{{#a}}
{{.}}
{{/a}}
to iterate over it. Now if we have some thing like
var a = [[1,2], [3,4], [5,6]]
Can we create a template like:
{{#a}}
key is {{0th element}} and the value is {{1st element}}
{{/a}}
Tried out things and got the solution: We can do the following:
var htm = '{{#names}}'+
'<p> value="{{0}}" key = "{{1}}"</p>'+
'{{/names}}';
ich.addTemplate('formNameOptionsHTML',htm);
var arr =[[0,1],[10,11],[20,21]];
var htm = ich.formNameOptionsHTML({names:arr});
$('body').append(htm);
Here is the jsfiddle link to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With