0

我是一个运行 CouchDB 1.0.1 的 couchdb 新手。

我有一个非常基本的问题。我无法让 Mustache Sections 在列表中呈现。这是我的列表,其中包含来自示例的硬编码数据。

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>

请帮忙!!!

谢谢你,/杰夫

4

1 回答 1

1

哦,巴夫,我刚刚想通了,这有点荒谬。这是为任何想要节省时间的人准备的。将此添加到您的模板“{{%IMPLICIT-ITERATOR}}”中。

所以:

var template = "{{name}}: <ul> {{#items}}<li>{{.}}</li>{{/items}} </ul>";

变成:

var template = "{{%IMPLICIT-ITERATOR}}{{name}}: <ul> {{#items}}<li>{{.}}</li>{{/items}} </ul>";
于 2010-12-09T03:42:51.693 回答