【发布时间】:2014-12-01 09:23:40
【问题描述】:
如何使用 Mustaches.js 在 CouchDB 中获取附件列表
JSON 示例:
{
"_id": "t",
"_rev": "9-5eed240a008b0eb6efbaf9a439c43279",
"_attachments": {
"Doc1.pdf": {
"content_type": "application/pdf",
"revpos": 8,
"digest": "md5-pxnGZT6uqX4n2+vNNIOs/g==",
"length": 200633,
"stub": true
},
"Doc2.pdf": {
"content_type": "application/pdf",
"revpos": 6,
"digest": "md5-fxnGZT6uqX2n2+vNNI41s/g==",
"length": 100333,
"stub": true
}
}
}
我的模板如下所示:
{{^isAttEmpty}}
<p>Lista załączników:<p>
<ul>
{{#_attachments}}
<li>{{@key}} - URL:{{This will be URL to Image}}</li>
{{/_attachments}}
</ul>
{{/isAttEmpty}}
Mustache.js 是否有内置函数来迭代对象?或者我应该在发送到 Mustaches 之前解析到数组?
【问题讨论】:
标签: javascript html templates couchdb mustache