Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 94878 invoked from network); 8 Dec 2010 20:17:50 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Dec 2010 20:17:50 -0000 Received: (qmail 24944 invoked by uid 500); 8 Dec 2010 20:17:49 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 24883 invoked by uid 500); 8 Dec 2010 20:17:49 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 24875 invoked by uid 99); 8 Dec 2010 20:17:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Dec 2010 20:17:49 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [98.139.52.200] (HELO nm3.bullet.mail.ac4.yahoo.com) (98.139.52.200) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 08 Dec 2010 20:17:38 +0000 Received: from [98.139.52.189] by nm3.bullet.mail.ac4.yahoo.com with NNFMP; 08 Dec 2010 20:17:17 -0000 Received: from [98.139.52.174] by tm2.bullet.mail.ac4.yahoo.com with NNFMP; 08 Dec 2010 20:17:17 -0000 Received: from [127.0.0.1] by omp1057.mail.ac4.yahoo.com with NNFMP; 08 Dec 2010 20:17:17 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 61125.37627.bm@omp1057.mail.ac4.yahoo.com Received: (qmail 38817 invoked by uid 60001); 8 Dec 2010 20:17:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1291839436; bh=Icn6QHadDMeKBFY79dAxK4BL79EU4BHUxIwHiAI69W4=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=3baYMG5BQ2Z8mlqR8PZOZirB31dQdcnI6fML1OfmwpU5qFynSl4vhBX/5wQ499BDcN1W9B5OQxEwoIps3yhUVsrxtxRseKrWwV178mWOPdEhfNCjgDwEjixegQIehRNGkxoeNASh9aCiLsv/jRfxlplfOhqyCmMUpQkGZoRVVT4= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=HBPmMd9LXBRqbDqK8i2CohMOHqdhJV8OiPV+stDFXWR1QOm4nCogl49A2QJ3QsMfVA910nopex5mNBKNTh3O19+7+IS4re3yXHVH06W2Ju9kInqZVfFkGP+Hy9al2v9eU7vwOK0eoo38i74rcNjvlWuEgsr2DVKLZMZLRCFvy+E=; Message-ID: <895639.37396.qm@web65704.mail.ac4.yahoo.com> X-YMail-OSG: gBfF09cVM1lGY_USlmN.tFQoPYbB5r5UlEiYFNscFenHhtN OpctlV6EZsPLxuidos8LYh4EH.QsCzrcbOzy497mnx_ixwFblB6tYxifpv1U 8kNOeHBxCeWqASTYzUL5xXmn808hKtT7Ux1Uar8nPOGEUXXGhzcvoIOBYhFA LsbYa7SSsEOT9w_2wcIl51NSQkexiwByuuanjBCIZ9Kmo_y6nWE6DoCYis17 D02FL_cYMR3rMbTiEEi.9n_3w5thy9HIoJyZVDRBzh4NFkauwejHVmAaiOwC AyvG8_Xdmku13poxDEaGqhPmbwABOQj_eoIfZlg-- Received: from [71.197.33.245] by web65704.mail.ac4.yahoo.com via HTTP; Wed, 08 Dec 2010 12:17:16 PST X-Mailer: YahooMailRC/553 YahooMailWebService/0.8.107.285259 Date: Wed, 8 Dec 2010 12:17:16 -0800 (PST) From: IOMATIX Subject: Couchdb Recusive Documents To: user@couchdb.apache.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1166428774-1291839436=:37396" X-Virus-Checked: Checked by ClamAV on apache.org --0-1166428774-1291839436=:37396 Content-Type: text/plain; charset=us-ascii 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 list. // 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"); start({ "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) { row.value[val]=mustache.to_html(row.value[val],row.value); } } if (response[row.value.type] == undefined) { response[row.value.type] = mustache.to_html(row.value.templates,row.value); } else { response[row.value.type] += mustache.to_html(row.value.templates,row.value); } } 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! --0-1166428774-1291839436=:37396--