A Browserify middleware that pre-compiles Jade templates on the server and uses the light-weight Jade runtime made for the browser to render them on the client.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.npmignore
.travis.yml
README.md
package.json

README.md

Browserijade

A Browserify middleware that pre-compiles Jade templates on the server and uses the light-weight Jade runtime made for the browser to render them on the client. Can be used to include jade files in the Browserify bundle or just to render pre-compiled templates on the client if for example templates are being AJAXed to the client.

Build Status

Installation

$ npm install browserijade

Running the tests

$ npm test

Example

Including all Jade templates with a connect-based framework like Express

Server-side:

var browserify = require("browserify"),
    browserijade = require("browserijade")

var bundle = browserify()
bundle.use(browserijade(__dirname + "/views", ['serverThing.jade'], {debug: true}))

app.use(bundle)

Client-side:

var browserijade = require("browserijade")

var article = browserijade("article", {title: "NEWS!"})
$("body").html(article)

Just rendering templates on the client-side without including any templates

Server-side:

var browserify = require("browserify")
var bundle = browserify()
app.use(bundle)

Client-side:

var browserijade = require("browserijade").renderString

// articleTemplate is a pre-compiled Jade template that could
// have been AJAXed to the client.
var article = browserijade(articleTemplate, {title: "NEWS!"})
$("body").html(article)