Jade介绍
http://jade-lang.com/
安装Jade
sudo npm install jade --global
Jade Get Started
http://jade-lang.com/tutorial/
http://jade-lang.com/reference/
Jade Template
touch t.jade
h1
| Maintainer:
= ' ' + maintainer.name
table
tr
td Twitter
td= maintainer.twitter
tr
td Blog
td= maintainer.blog
touch j.js
var jade = require('jade'),
fs = require('fs');
var data = {
maintainer: {
name: 'Forbes Lindesay',
twitter: '@ForbesLindesay',
blog: 'forbeslindesay.co.uk'
}
}
fs.readFile('./t.jade', 'utf8', function (err, t) {
if (err) throw err;
var fn = jade.compile(t);
var html = fn(data);
console.log(html);
});
node j.js > o.html
Reference:
http://stackoverflow.com/questions/13362381/how-to-compile-jade-template-file-to-get-string