jaderunner
v0.0.4
Published
Executes Jade templates
Downloads
7
Maintainers
Readme
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"]
- If
-a
is set use<asset_home>
for global path to other Jade assets, otherwise use the value of theASSET_HOME
environment variable - Loads and compiles the Jade template
<template_file>
- If
-j
is specified, read<json_data>
as locals - If
"json_string"
is present, evaluate it and add result to locals - Execute template using locals
- 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 templatesource
: source of templateoptions
: compilation optionsfunc(object)
: Jade compiled template functionrender(string, object)
: runs the template with theobject
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