I have done something via JavaScript and implemented in Mustache.
Note: Code is not pure Mustache
JS Code
var mustacheFormattedData = {
'value': []
};
for (var row in tableRows) {
if (tableRows.hasOwnProperty(row)) {
var obj = tableRows[row]
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
console.log(prop)
mustacheFormattedData['value'].push({
'value': obj[prop]
});
}
}
}
}
JSFiddle
If the person key exists and is not null, undefined, or false, and is not an empty list the block will be rendered one or more times.
When the value is a list, the block is rendered once for each item in the list. The context of the block is set to the current item in the list for each iteration. In this way we can loop over collections.
View:
{
"stooges": [
{ "name": "Moe" },
{ "name": "Larry" },
{ "name": "Curly" }
]
}
Template:
{{#stooges}}
<b>{{name}}</b>
{{/stooges}}
Refer this