From user-return-22643-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sat Oct 27 20:20:37 2012 Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 116F2DCBF for ; Sat, 27 Oct 2012 20:20:37 +0000 (UTC) Received: (qmail 13471 invoked by uid 500); 27 Oct 2012 20:20:35 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 13413 invoked by uid 500); 27 Oct 2012 20:20:35 -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 13402 invoked by uid 99); 27 Oct 2012 20:20:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Oct 2012 20:20:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.220.52] (HELO mail-pa0-f52.google.com) (209.85.220.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Oct 2012 20:20:26 +0000 Received: by mail-pa0-f52.google.com with SMTP id hz10so2456499pad.11 for ; Sat, 27 Oct 2012 13:20:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=61UtNayJS7dPlVlRuHedexfeU9lm/BKdBZIGhJzP8PU=; b=kw/hHAKdaGVrvOMeE8s0Ex16jOrXfewVpvnf059vzLGC6BId5Dnfsa973x9v6iFDfu 2wPjh1nkwfKzfDTk4072MIRJ7ROKGlSNQ3WT+p52fRPNelVCovhVhECX4T55f2URpFvP Sur3psh9LyEMowDc/Y8Xdhux36tBxvODZy/UFXNDACiV29Po9VVjoObjvSou5XXUjsrM N3iZkDBVTl0+xWiUJwl7NnnaBpyWbSJyJWTlYcEnfJaoOkjbjhHHslhmrFC/TyarriEy JVKu4ehrKDey1USPfd+WTVEjaQNVdpRaNlgRvyoT8FW6Rf/1ciGrIUOYcXLvT828D+aS WG/A== Received: by 10.68.224.132 with SMTP id rc4mr80207753pbc.155.1351369206134; Sat, 27 Oct 2012 13:20:06 -0700 (PDT) Received: from postel.lan (71-80-152-172.dhcp.mdfd.or.charter.com. [71.80.152.172]) by mx.google.com with ESMTPS id pj10sm3244198pbb.46.2012.10.27.13.20.04 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 27 Oct 2012 13:20:05 -0700 (PDT) Subject: Re: Right place for mustache.js Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=us-ascii From: Nathan Vander Wilt In-Reply-To: <5062EA94.10102@gmail.com> Date: Sat, 27 Oct 2012 13:20:26 -0700 Cc: Aliaksandr Barysiuk Content-Transfer-Encoding: quoted-printable Message-Id: <2E2B0FB8-4237-417F-A6C3-BAD5E540CD56@calftrail.com> References: <5062EA94.10102@gmail.com> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1283) X-Gm-Message-State: ALoCoQkczUFobVm+6Gt+aYlUKP8tvVn55iUJIbercpMTviICpm+4qdqkI49xHMSGhlai7ixiCEFo X-Virus-Checked: Checked by ClamAV on apache.org Hello Aliaksandr, and sorry this did not get an answer earlier. Assuming = you figured it out by now, but for the archives the documentation on = this is currently here: http://wiki.apache.org/couchdb/CommonJS_Modules In short, there's not a great "standard" way to do either. Both couchapp = and kanso.js let you easily include this code in both places, = though...with couchapp I just symlink any shared attachments into a lib = dir. If you really hate to duplicate, you could expand the "real code" = equivalent of `` inline into = your generated HTML. Accessing the design doc itself via `this` in a = _show/_list (or any other) function is a simple way to load templates = without needing to statically include them (e.g. = `this.templates['name']`), or if you're using a pre-compiling template = engine of course the templates can be require()'d just as other code. hope this helps, -natevw On Sep 26, 2012, at 4:44 AM, Aliaksandr Barysiuk wrote: > Hello, >=20 > We're using mustache.js template engine in our lists/shows in the = couchapp. Basically it is included like 'var mustache =3D = require(lib/mustache)'. Now we also need mustache.js on the client side. = What is the best place for it to avoid duplication? As i understand = client can access to '_attachments' while lists/shows cannot. >=20 > And one extra question here: is it possible to load templates = dynamically in the show or list? We're able to include them statically = via '!json templates.index'. >=20 > Thank's