希望在这里迭代每个“内容”项:
"content": {
"0": {
"artifact_id": "36",
"timestamp": "2013-08-20 11:59:00",
"modified": "2013-08-20 11:59:00",
"text": "Why did the last one duplicate? I don't think I clicked it twice...",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"1": {
"artifact_id": "35",
"timestamp": "2013-08-20 11:57:51",
"modified": "2013-08-20 11:57:51",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"2": {
"artifact_id": "34",
"timestamp": "2013-08-20 11:57:50",
"modified": "2013-08-20 11:57:50",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
}
}
使用 Handlebars 可以轻松做到这一点吗?我似乎找不到在模板内自动迭代的方法。现在我有:
{{#content}}
{{#arr}}
<li>
{{text}}
</li>
{{/arr}}
{{/content}}
</script>
var html = Mustache.to_html(template, {content:arr});