安装配置
1 安装:
npm install pug-cli -g
jade --help
Usage: jade [options] [dir|file ...]
Options:
-h, --help output usage information / 输出使用信息
-V, --version output the version number / 输出版本号信息
-O, --obj <str> javascript options object / 传输到 jade 文件中的数据对象
-o, --out <dir> output the compiled html to <dir> / 输出编译后的 HTML 到 <dir>
-p, --path <path> filename used to resolve includes / 在处理 stdio 时,查找包含文件时的查找路径
-P, --pretty compile pretty html output / 格式化编译 html 文件
-c, --client compile function for client-side runtime.js / 编译浏览器端可用的 runtime.js
-n, --name <str> The name of the compiled template (requires --client) / 编译模板的名字
-D, --no-debug compile without debugging (smaller functions) / 关闭编译的调试选项(函数会更小)
-w, --watch watch files for changes and automatically re-render / 监听文件改变并自动刷新编译结果
--name-after-file Name the template after the last section of the file path (requires --client and overriden by --name)
--doctype <str> Specify the doctype on the command line (useful if it is not specified by the template) / 在命令行中指定文档类型(如果在模板中没有被指定)
Examples:
# 编译整个目录
$ jade templates
# 生成 {foo,bar}.html
$ jade {foo,bar}.jade
# 在标准IO下使用jade
$ jade < my.jade > my.html
# 在标准IO下使用jade
$ echo 'h1 Jade!' | jade
# foo, bar 目录渲染到 /tmp
$ jade foo bar --out /tmp
2实例 编写与运行
第一步:打开sublime 创建studyJade.jade 保存到桌面上
doctype html html head title jade body p studyjade div hello jade
第二步: 打开终端执行 $ jadestudyJade.jade -P(大写P: 格式化编译html 文件), 然后桌面上会出现对应的studyJade.html文件;