couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "john.tiger" <john.tigernas...@gmail.com>
Subject Re: using mustache in couchapp
Date Thu, 16 Feb 2012 07:55:59 GMT
On 02/16/2012 12:08 AM, Nathan Vander Wilt wrote:
> On Feb 15, 2012, at 5:01 PM, john.tiger wrote:
>> assuming my app.js and mustache.js are in the same attachments folder - when I've
used:
>> var Mustache = require('mustache');
>> =>  require not found
>>
>> do I have to include require.js as well ?
> If you want to use JavaScript on the server side, you'll need to store it as a *property*
on your design doc. So in a "lib" folder (outside of _attachments) with the 'couchapp' it
will get included like:
>
>
> couchapp folder
>    _id file
>    |_ _attachments folder
>        |_ ...clientside media...
>    |_ lib folder
>        |_ mustache.js
>
> <---->
>
> {_id:"<file contents>", _attachments: {...}, lib:{mustache:"<file contents>"}}
>
> Then you would use it in a _show/_list/_update function with `var Mustache = require('lib/mustache')`.
When I do need a library both server and clientside with 'couchapp', I tend to symlink it
so it appears in both _attachments and other properties.
>
>
> hope this helps,

yes, it does - thks.

Mime
View raw message