couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Vander Wilt <nate-li...@calftrail.com>
Subject Re: Right place for mustache.js
Date Sat, 27 Oct 2012 20:20:26 GMT
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 `<script>{{{this.lib.mustache}}}</script>`
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,
> 
> We're using mustache.js template engine in our lists/shows in the couchapp. Basically
it is included like 'var mustache = 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.
> 
> 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'.
> 
> Thank's


Mime
View raw message