jade2commonjs

0.1.0 • Public • Published

Jade2Commonjs

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.

Installation

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

Usage

$ 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.

Options

-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).

Examples

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

Readme

Keywords

none

Package Sidebar

Install

npm i jade2commonjs

Weekly Downloads

3

Version

0.1.0

License

AGPL-3.0

Last publish

Collaborators

  • mycozycloud