Thanks Jason - sorry, another question. When you say "<insert mustache.js CommonJS file here>" what do you mean?
I found this: http://github.com/janl/mustache.js/tree/master/mustache-commonjs but I'm unsure what I need to copy into the design doc. On 16 August 2010 19:35, Jason Smith <[email protected]> wrote: > On Mon, Aug 16, 2010 at 23:04, Michael Lenahan <[email protected] > >wrote: > > > 1. I wasn't able to work out how templating languages like mustache fit > in. > > Are there any ways to use mustache inside a "show" to make authoring the > > show more easy? > > > > In a show function, the `this` variable is assigned to the Javascript > object > of the design doc. Therefore if your design doc is > > { "_id": "_design/default", > "mustache_lib": "<insert mustache.js CommonJS file here>", > "an_html_template": "This is a web page called {{name}}", > etc. > } > > Then you can load mustache via CommonJS in the show function. > > function(doc, req) { > var mustache = require("mustache_lib"); > var template = this.an_html_template; > return {body: mustache.to_html(template, {name: "Hi!"}); > } > > That is the idea, note I did not test this code just yet but I got it from > working code I use. > > -- > Jason Smith > Couchio Hosting >
