2010-12-09 2 views
0

저는 CouchDB 1.0.1을 실행하는 couchdb 초보자입니다.Couchdb 이슈의 콧수염 섹션

저는 아주 기본적인 문제가 있습니다. 나는 콧수염 섹션을 목록에 렌더링 할 수 없습니다. 예를 들어 하드 코딩 된 데이터가있는 목록입니다.

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> 

도와주세요!

난 그냥 그것을 알아 냈어, /제프

답변

1

오 발프 감사하고 조금 rediculous이다. 여기는 시간을 절약하고자하는 다른 모든 사람들을위한 것입니다. 이것을 템플릿 "{{% IMPLICIT-ITERATOR}}"에 추가하십시오.

그래서 :

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

가된다 :

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