Here is the JSON data:
var details = [
{
"event": {
"name": "txt1",
"date": "2011-01-02",
"location": "Guangzhou Tianhe Mall"
}
},
{
"event": {
"name": "txt2",
"date": "2011-01-02",
"location": "Guangzhou Tianhe Mall"
}
},
{
"event": {
"name": "txt3",
"date": "2011-01-02",
"location": "Guangzhou Tianhe Mall"
}
}
];
And this is my mustache template:
{{#event}}
<div>
<h2>{{name}}</h2>
<span>on {{date}}</span>
<p>{{location}}</p>
</div>
{{/event}
The current template code above does not work. I am now trying to figure out a way to make it work without using a loop:
var output = Mustache.render(template, details);
Is there a more efficient method to achieve this without the need for a loop?