A simple cli tool to wrap jade generated functions into commonjs modules
Last updated 4 years ago by mycozycloud .
AGPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install jade2commonjs 
SYNC missed versions from official npm registry.


Simple CLI tool to wrap jade generated functions into commonjs modules.

We sometimes need to export Jade templates to JavaScript functions, but need them to be wrapped in CommonJS modules to be able to import them later. Compiling to JS functions is properly handled by Jade lib/CLI, but wrapping in modules isn't. This tool does it.


Install it via NPM/Github globally or in your project. You'll need the Jade/Pug runtime to get you modules working when you'll import them later. The runtime is installed for NPM < 2.x as peer dependency, which is not wiith NPM 3. If you use NPM 3, you need to install it manually.

$ npm install [--global] --save-dev cozy/jade2commonjs
# if you use NPM 3, in your project
$ npm install --save pug-runtime


$ jade2commonjs [options] [dir|file ...]

Render files and dirs into CommonJS modules files. When passing dirs, the directories are parsed recursively and tree is preserved on output.


-h, --help              output usage information
-V, --version           output the version number
-o, --out <dir>         output the compiled js modules to <dir>
-p, --path <path>       filename used to resolve includes
-D, --no-debug          compile without debugging (smaller functions)
-i, --ignore [pattern]  anymatch patterns to ignore when compiling <dir> (repeatable)

if you're familiar to the jade-cli, this is a smaller version of their options. Jade2Commonjs adds a ignore flag that you can use to exclude some files to compile (such as partials).


Render all files in server/views in same folders as originals:

$ jade2commonjs server/views

Render all files in server/views in a template folder:

$ jade2commonjs --out templates server/views

Render all files in server/views but partials (starting with _) and index.jade, without debug statements:

$ jade2commonjs --no-debug --ignore '**/_*.jade' --ignore 'index.jade' server/views

Current Tags

  • 0.1.0                                ...           latest (4 years ago)

1 Versions

  • 0.1.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (0)

Copyright 2014 - 2016 © taobao.org |