Couchdb问题中的“胡子"部分 [英] Mustache section in Couchdb issues

查看:65
本文介绍了Couchdb问题中的“胡子"部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个运行CouchDB 1.0.1的ouchdb新手.

I am a couchdb newbie running CouchDB 1.0.1.

我有一个非常基本的问题.我无法在列表中显示胡子"部分. 这是我的清单,其中包含来自示例的硬编码数据.

I have a very basic issue. I cannot get Mustache Sections to render in a list. Here is my list with the data hard coded from an example.

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>

请帮助!!!

谢谢你, /杰夫

推荐答案

哦,barf,我刚刚弄清楚了,有点荒谬.这是给其他想要节省时间的人的.将此添加到您的模板"{{%IMPLICIT-ITERATOR}}".

Oh barf, I just figured it out and it is a little rediculous. Here it is for anyone else who wants to save some time. Add this to your template "{{%IMPLICIT-ITERATOR}}".

所以:

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

成为:

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

这篇关于Couchdb问题中的“胡子"部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆