Template Loaders

Installation

Via NPM:

$ npm install wjst --global

Usage

$ wjst compile [file...] [options]
$ wjst render [file...] [options]
$ wjst run [file...] [options]

Options

-v, --version  Show the Wjst version number.
-o, --output   Output location. [default: "stdout"]
-h, --help     Show this help screen.
-j, --json     Variable context as a JSON file.
-c, --context  Variable context as a CommonJS-style file. Used only if option `j` is not provided.
-m, --minify   Minify compiled functions with uglify-js
--filters      Custom filters as a CommonJS-style file
--tags         Custom tags as a CommonJS-style file
--options      Customize Wjst's Options from a CommonJS-style file
--wrap-start   Template wrapper beginning for "compile". [default: "var tpl = "]
--wrap-end     Template wrapper end for "compile". [default: ";"]
--method-name  Method name to set template to and run from. [default: "tpl"]

Examples

Render a single file:

$ wjst render ./index.html

Compile and cache a template into a renderable function and minify the output with uglify-js:

$ wjst compile ./index.html -m > ./cache/index.js

Run and build the previously cached template:

$ wjst run ./cache/index.js

Import a JSON file as the variable context for rendering a template:

$ wjst render ./index.html -j ./index.json

Make your template an AMD module:

$ wjst compile ./index.html --wrap-start="define(function () { return " --wrap-end="; });"