我是一个运行couchdb 1.0.1的CouchDB新手。
我有一个非常基本的问题。我不能让Mustache部分在列表中呈现。以下是我的列表,其中包含来自示例的硬编码数据。
function(head, req) {
start({
"headers": {
"Content-Type": "text/html"
}
});
var mustache = require("lib/mustache");
var view = {name: "Joe's shopping card",items: ["bananas", "apples"]};
var template = "{{name}}: <ul> {{#items}}<li>{{.}}</li>{{/items}} </ul>";
return mustache.to_html(template,view);输出:
Joe's shopping card: <ul> <li></li><li></li></ul>请帮帮我!
谢谢你,/ Jeff
发布于 2010-12-09 11:42:52
哦,天哪,我刚想通了,这有点离经叛道。这里是为其他想节省时间的人准备的。将其添加到您的模板"{{%IMPLICIT-ITERATOR}}“。
所以:
var template = "{{name}}: <ul> {{#items}}<li>{{.}}</li>{{/items}} </ul>";变成:
var template = "{{%IMPLICIT-ITERATOR}}{{name}}: <ul> {{#items}}<li>{{.}}</li>{{/items}} </ul>";https://stackoverflow.com/questions/4394595
复制相似问题