jade-renderer

Render a collection of Jade templated from one location to another

npm install jade-renderer
5 downloads in the last week
23 downloads in the last month

Build Status

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

Install

npm install jade-renderer

Usage

var render = require('jade-renderer')

render(pages, options, cb)

  • 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'
  , fn: function () {
      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!')
  })
npm loves you