Last Updated: February 25, 2016
·
1.141K
· pheuter

require-j: Client-side Jade with template inheritance

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.

GitHub repo