incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robin Berjon <ro...@berjon.com>
Subject Re: Couchdb and Handlebars
Date Wed, 10 Oct 2012 07:49:05 GMT
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 = "<div>{{user}}</div>"
>      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

-- 
Robin Berjon - http://berjon.com/ - @robinberjon

Mime
View raw message