incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Couchdb Recusive Documents
Date Wed, 08 Dec 2010 20:17:16 GMT
Hi Everyone,

What I am trying to do with Mustache and a List:
Put basically, I want to create a tree with,
parent (called from browser): Document and its fields rendered into one template
children: Then render any docs that are members of the top document and render 
them in the parent template

I'm stuck on trying to get partials to render and thought the below was a  
mess.  Then I thought, hey there are way smarter people who  might be able to 
help or at least show me how to approach this better :)

What I have in a list:
//Take all the fields in a document and render (parse mustache vars and  
partials) into a template field in the same document using Mustache and a  list 
recursively.  Then look for specific document types to parse into  the called 
// This takes all the fields and renders them into the document template of type 
page and then renders all related documents based on there types
function(head, req) {
    var row,
        response = new Array(),
        mustache = require("lib/mustache");

        "headers": {
            "Content-Type": "text/html"
    while(row = getRow()) {
        for(val in row.value) {
            if (val!='templates' && row.value.type!='page' && 
row.value[val].indexOf('{{')!=-1) {
        if (response[row.value.type] == undefined) {
            response[row.value.type] = 
        else {
            response[row.value.type] += 
    return mustache.to_html(response['page'],response);

Thank you,
/ Jeff

Me briefly:
I come from 10+ years of LAMP programming and relational database nightmares.  
So thank you for your help! 

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message