不是说jade怎么写 而是jade怎么在返回成前台页面 不用express的情况下 小白求问 0.0
那你还是用express吧, 或者自己写脚本把jade模板编译成html页面。 ejs的调用大概是这样的, var html=ejs.renderFile(template,json); var fs=require(“fs-extra”); fs.createFileSync(file); fs.writeFileSync(file,html);
= =必须用express么 这不科学
就如@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
多谢回答 怎么我一调用var jade = require(‘jade’);就会报错 [ReferenceError: process is not defined] 难道是缺少什么模块吗
你可以直接npm install jade 然后再试一下,应该是模块没有安装的问题。
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
那你还是用express吧, 或者自己写脚本把jade模板编译成html页面。 ejs的调用大概是这样的, var html=ejs.renderFile(template,json); var fs=require(“fs-extra”); fs.createFileSync(file); fs.writeFileSync(file,html);
= =必须用express么 这不科学
就如@ldjking所說,如果你不用express,就直接compile成static html.
多谢回答 怎么我一调用var jade = require(‘jade’);就会报错 [ReferenceError: process is not defined] 难道是缺少什么模块吗
你可以直接npm install jade 然后再试一下,应该是模块没有安装的问题。