Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Example browserify transform which precompiles Jade
// templates including them in the bundle, allowing you
// to use:
// var tmpl = require('./templates/template.jade');
// Supports layouts and blocks
// requirements:
// npm install jade through
// command line:
// browserify -t ./browserify-v2.jade.js main.js -o bundle.js
var through = require('through'),
jade = require('jade');
module.exports = function (file) {
if (!/\.jade$/.test(file)) return through();
var data = '';
return through(write, end);
function write (buf) { data += buf }
function end () {
var result = compile(file, data);
module.exports.root = null;
function compile(file, tmpl) {
var fn = jade.compile(tmpl, {
client: true,
path: __dirname
return ["var jade = require('jade/lib/runtime.js');",

This comment has been minimized.

Copy link

commented Mar 23, 2013

Thanks for sharing this! Using it myself now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.