I installed jade (npm install jade) and went over to their github page to grab some examples. This is what I wanted to execute:
code.jade:
- var titl
It looks like newer versions of Jade use a different API, there is no more 'renderFile' method. Take a look at the 'Public API' section on here: https://github.com/visionmedia/jade
Something like this is probably what you want. Just remember you only need to read the file once. If you are doing it dynamically, be sure not to read it synchronously.
var jade = require('jade');
var fs = require('fs');
var jadetemplate = jade.compile(fs.readFileSync('code.jade', 'utf8'));
var html = jadetemplate({
users: {
tj: { age: 23, email: 'tj@vision-media.ca', isA: 'human' },
tobi: { age: 1, email: 'tobi@is-amazing.com', isA: 'ferret' }
}
});
console.log(html);
This answer was valid when it was written, however renderFile
was added back in several months later in 92c314, so it may be used now.