A flatiron plugin for Jade Templating Language.
npm install jade-flatiron
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
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.
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.