jade-renderer

Render a collection of Jade templated from one location to another

Render batches of jade templates, with custom options, data and locals.

npm install jade-renderer
var render = require('jade-renderer')
  • pages an array of 'pages' to render. 'pages' look like this:
{ template: 'path/to/template'
, data:
  { text: 'some arbitrary data'
  , more: 'to pass to the template'
  , fnfunction () {
      return 'may contain any js, including functions'
    }
  }
}
  • options is an options hash
    • src the source directory, defaults to PWD
    • dest the destination directory, defaults to PWD
    • locals locals to be passed to all views that are rendered (useful for view helpers)
  • cb is the callback function (err) {} (err is null if ok)

Eg:

render(
    [ { template: 'index', data: { title: 'Index'} }
    , { template: 'about', data: { title: 'About'} }
    ]
  , { src: __dirname
    , dest: __dirname + '/html/'
    }
  , function (err) {
    if (err) throw err
    console.log('done!')
  })