Skip to content

Instantly share code, notes, and snippets.

@ryanfitz
Created February 19, 2011 02:26
Show Gist options
  • Save ryanfitz/834768 to your computer and use it in GitHub Desktop.
Save ryanfitz/834768 to your computer and use it in GitHub Desktop.
render jade templates on client side using stitch
var stitch = require('stitch');
var express = require('express');
options = {
paths : [__dirname + '/lib', __dirname + '/vendor'],
compilers: {
jade: function(module, filename) {
var jade = require('jade');
var source = require('fs').readFileSync(filename, 'utf8');
source = "module.exports = " + jade.compile(source) +";";
module._compile(source, filename);
}
}
}
var package = stitch.createPackage(options);
var app = express.createServer();
app.configure(function(){
app.use(express.staticProvider(__dirname + '/public'));
});
app.get('/application.js', package.createServer());
app.listen(4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment