Express---jade模板引擎(二)

安装配置


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文件;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值