标签:
index.jade
//cmder
jade index.jade -P
编译后的index.html 文件:
模板的继承
layout.jade文件:
doctype html
head
meta(charset=‘utf-8‘)
body
block desc
p extends from layout
block content
index.jade文件:
extends layout
block content
h2 模板继承
模板的包含
include head
jade核心API
//安装模块
npm install jade coffee-script less markdown --save
Jade was renamed to Pug[红字加粗]
var http = require(‘http‘);
var jade = require(‘jade‘);
http.createServer(function (req, res) {
res.writeHead(200, {‘Content-Type‘: ‘text/html‘});
//1. compile
//var fn = jade.compile(‘div #{course}‘, {});
//var html = fn({course: ‘jade‘});
//2.jade.render
//var html = jade.render(‘div #{course}‘, {course: ‘jade render‘});
//3.jade.renderFile
//pretty: true 意思是格式化
var html = jade.renderFile(‘index.jade‘, {course: ‘jade renderFile‘, pretty: true});
res.end(html);
}).listen(1337, ‘127.0.0.1‘);
console.log(‘server running as 1337‘);
标签:
原文地址:http://www.cnblogs.com/lqcdsns/p/5438182.html