here is the JSON:
var data = [
{
"event": {
"name": "txt1",
"data": "2011-01-02",
"address": "Guangzhou Tianhe Mall"
}
},
{
"event": {
"name": "txt2",
"data": "2011-01-02",
"address": "Guangzhou Tianhe Mall"
}
},
{
"event": {
"name": "txt3",
"data": "2011-01-02",
"address": "Guangzhou Tianhe Mall"
}
}
];
and my mustache template is:
{{#event}}
<div>
<h2>{{name}}</h2>
<span>on {{data}}</span>
<p>{{address}}</p>
</div>
{{/event}
so the template code above don not work.What I do now is make a for
loop :
var html = "";
for(var i = 0; i < data.length; i++){
html += Mustache.to_html(tmp, data[i]);
}
Any better way to make it works without any loop?