jaderunner

0.0.4 • Public • Published

jaderunner

Simple package for executing Jade templates from the command-line.

Install

npm install --save jaderunner

Usage

jaderunner [-a <asset_home>] [-j <json_data>] <template_file> <output_file> ["json_string"]
  1. If -a is set use <asset_home> for global path to other Jade assets, otherwise use the value of the ASSET_HOME environment variable
  2. Loads and compiles the Jade template <template_file>
  3. If -j is specified, read <json_data> as locals
  4. If "json_string" is present, evaluate it and add result to locals
  5. Execute template using locals
  6. Write output HTML to <output_file>

Examples

// Execute simple.jade and write to out.html
jaderunner simple.jade out.html

// The same, using default extensions 
jaderunner simple out

// Supply some locals to the template
jaderunner simple out "{title:'The title',x:42}"

// Read locals from data.json
jaderunner -j data.json simple out
jaderunner -j data simple out

API

jaderunner.compile(string, [object])

Example: jaderunner.compile('template.jade')

Loads and compiles a Jade template, returning an object with the keys:

  • source_file: file name of Jade template
  • source: source of template
  • options: compilation options
  • func(object): Jade compiled template function
  • render(string, object): runs the template with the object as its locals, and writes the output to the file given by the first parameter

E.g.

var tmpl = jaderunner.compile('simple.jade');
tmpl.render('output.html', {
  title: 'My title'
});

License

MIT © James Skinner

Package Sidebar

Install

npm i jaderunner

Weekly Downloads

1

Version

0.0.4

License

MIT

Last publish

Collaborators

  • spiralx