node package manager

jade-flatiron

Jade FlatIron Plugin

Description

A flatiron plugin for Jade Templating Language.

Install

npm install jade-flatiron

Usage

var jade = require('jade-flatiron');
 
app.use(jade({path: __dirname + '/views'}));
 
app.router.get('/', function() {
  app.render('index', { title: 'App' }, function(err, html) {
    this.res.writeHead(200, { 'Content-Type': 'text/'html' });
    this.res.end(html);
  });
});
 
app.start(3000);
 
jade = require 'jade-flatiron'
 
app.use jade(path: [__dirname'views'].join('/'))
 
app.router.get '/'->
  app.render 'index'title: 'App'(err, html) ->
    @res.writeHead 200'Content-Type': 'text/html'
    @res.end html
 
 
app.start 3000

API

On the Attach method, or when the plugin is being called by the app use method. You need to pass in the template path, otherwise the plugin will default to the views directory.

this.render method

The render method uses the default template path and then takes the first parameter which is the filename and attempts to locate the template file. The second parameter is for optional data that can be passed as a Javascript Object.