码迷,mamicode.com
首页 > 其他好文 > 详细

三、Jade

时间:2016-04-27 12:52:43      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

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‘);

三、Jade

标签:

原文地址:http://www.cnblogs.com/lqcdsns/p/5438182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!