/require-j

RequireJS Jade plugin that supports client-side Jade rendering, including template inheritance.

Primary LanguageCoffeeScriptMIT LicenseMIT

require-j

RequireJS Jade plugin that supports client-side Jade rendering, including template inheritance.

About

require-j attempts to fill the gap left by porting jade over to the client, namely the ability to use template inheritance constructs such as extends and include.

To load templates, jade depends on certain node modules (such as path and fs) to exist during runtime and uses require to access them. The problem is that node's require is replaced by RequireJS's require which has no notion of node modules.

To address this issue, require-j overrides jade's default parseInclude and parseExtends functions with a variant that utilizes RequireJS APIs, such as toUrl and fetchText. This is achieved without any modifications to the jade library.

Todo

  • Refactor load to support dynamic loading from the browser

Dependencies

Setup

Initialize jade submodule

$ git submodule init
$ git submodule update

Install dependencies

$ npm install

Build plugin and demo app

$ cake build

Will create lib/j.js and demo/main.out.js

Usage

Check out the demo app in demo/ for a sample app utilizing require-j