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

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

Current Tags

  • 0.1.0                                ...           latest (4 years ago)

1 Versions

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

Copyright 2014 - 2017 © taobao.org |