CNode

jade要怎么变成前台页面

Wwbb123yu发布于13 年前最后回复13 年前5 回复5604 浏览0 收藏

不是说jade怎么写 而是jade怎么在返回成前台页面 不用express的情况下 小白求问 0.0

查看回复

回复 (5)

L
ldjking#1·13 年前

那你还是用express吧, 或者自己写脚本把jade模板编译成html页面。 ejs的调用大概是这样的, var html=ejs.renderFile(template,json); var fs=require("fs-extra"); fs.createFileSync(file); fs.writeFileSync(file,html);

H
hankwang#3·13 年前

就如@ldjking所說,如果你不用express,就直接compile成static html.

$ jade -w jadedir -o outdir
$ 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
    -o, --out <dir>    output the compiled html to <dir>
    -p, --path <path>  filename used to resolve includes
    -P, --pretty       compile pretty html output
    -c, --client       compile function for client-side runtime.js
    -D, --no-debug     compile without debugging (smaller functions)
    -w, --watch        watch files for changes and automatically re-render

  Examples:

    # translate jade the templates dir
    $ jade templates

    # create {foo,bar}.html
    $ jade {foo,bar}.jade

    # jade over stdio
    $ jade < my.jade > my.html

    # jade over stdio
    $ echo "h1 Jade!" | jade

    # foo, bar dirs rendering to /tmp
    $ jade foo bar --out /tmp
W
wbb123yu#4·13 年前
引用 hankwang就如@ldjking所說,如果你不用express,就直接compile成static html. $ jade w jadedir o outdir

多谢回答 怎么我一调用var jade = require('jade');就会报错 [ReferenceError: process is not defined] 难道是缺少什么模块吗

L
ldjking#5·13 年前

你可以直接npm install jade 然后再试一下,应该是模块没有安装的问题。

参与回复
登录后即可参与回复。登录