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 3D148DEDE for ; Wed, 10 Oct 2012 08:44:57 +0000 (UTC) Received: (qmail 1102 invoked by uid 500); 10 Oct 2012 08:44:55 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 784 invoked by uid 500); 10 Oct 2012 08:44: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 738 invoked by uid 99); 10 Oct 2012 08:44:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Oct 2012 08:44:47 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of a.barysiuk@gmail.com designates 209.85.217.180 as permitted sender) Received: from [209.85.217.180] (HELO mail-lb0-f180.google.com) (209.85.217.180) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Oct 2012 08:44:40 +0000 Received: by mail-lb0-f180.google.com with SMTP id ge1so237870lbb.11 for ; Wed, 10 Oct 2012 01:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=skzjNz8TlsyZt7ly/K0GFrY6/9PtqOBiZYWSGah8IuA=; b=nSu20QaE862wkOg6hEHIC656N8jNnw8axhLQOFd2eQTf+ww0vUVmgskriYqr2RjFz7 hB5X2D0ccRUmnhRvp1QhZIOpIoWCRhyVF+iBwmaY7qmzEdTugUyPw3s78KUvACJzYi9i FNJ02q3NkkKFLYbjRlAmn4LJG43YY8sbTbVJxmHh0YJY+MJY5KB6TxxFQw3leMaV2BsG vx/Om+fRSiH+v9/3NTpHWIczI62r9fskKZTloqEExzSrP9TWZH7cbRp3kKbyPTUXd+qw h/QfaNrMHFUaJJI7BZ9C12Y+EBzs2z/Ac7b/RawljaqquKjkUMexYqms5FCMvJMljLWQ ys/w== Received: by 10.152.124.111 with SMTP id mh15mr19181487lab.20.1349858660408; Wed, 10 Oct 2012 01:44:20 -0700 (PDT) Received: from [192.168.9.11] ([86.57.158.234]) by mx.google.com with ESMTPS id mq9sm234252lab.0.2012.10.10.01.44.19 (version=SSLv3 cipher=OTHER); Wed, 10 Oct 2012 01:44:20 -0700 (PDT) Message-ID: <50753564.3080907@gmail.com> Date: Wed, 10 Oct 2012 11:44:20 +0300 From: Aliaksandr Barysiuk User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120910 Thunderbird/15.0.1 MIME-Version: 1.0 To: Robin Berjon CC: user@couchdb.apache.org Subject: Re: Couchdb and Handlebars References: <50743DD1.9080807@gmail.com> <50752871.3070900@berjon.com> In-Reply-To: <50752871.3070900@berjon.com> Content-Type: multipart/alternative; boundary="------------060508090900040602060407" --------------060508090900040602060407 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Robin, Thank's for the answer. But does Couchdb support AMD modules? I only found CommonJS info ( http://wiki.apache.org/couchdb/CommonJS_Modules). However using patched Handlebars with 'require('lib/handlebars')' or 'require(['lib/handlebars'], function(module) { ...})' failed. The former with 'define is not defined' error, the latter with 'name.split is not a function' error. On 10/10/12 10:49, Robin Berjon wrote: > Hi, > > On 09/10/2012 17:08 , Aliaksandr Barysiuk wrote: >> I faced with issues when i have tried to use Handlebars >> (http://handlebarsjs.com/) in my show function. It seems it's CommonJS >> compliant but following simple example fails... >> >> function(doc, req) { >> >> var Handlebars = require('lib/handlebars'); >> var source = "
{{user}}
" >> var template = Handlebars.compile(source); >> return template( { user:"John" } ); >> } >> >> ...with error: >> >> {"error":"render_error","reason":"function raised error: (new >> TypeError(\"Handlebars.compile is not a function\", \"\", 4) ... > > This looks like Handlebars is not AMD friendly. It probably tries to define a global Handlebars object, which > obviously won't work here. > > What you need to do is wrap the lib so that it'll work with AMD. I haven't checked it out closely, but maybe this > patch can help: > > https://github.com/wycats/handlebars.js/pull/187 > --------------060508090900040602060407--