3

我想配置jade引擎来处理我的views文件夹中的.html文件。这是我当前的服务器配置:

app.configure(function(){
  var pub_dir = __dirname + '/public';
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser());
  app.use(express.session({ secret: nconf.get("site:secret") }));
  app.use(everyauth.middleware());  
  app.use(require('less-middleware')({ src: pub_dir, force:true }));
  app.use(express.static(pub_dir)); 
  app.use(app.router);
  app.use(logErrors);
  app.use(clientErrorHandler);
  app.use(errorHandler);
});
4

2 回答 2

6

https://github.com/visionmedia/express/blob/master/examples/ejs/index.js

app.engine('.html', require('jade').__express);
于 2012-08-20T23:09:49.323 回答
1

确保你已经jade在你的node_modules

npm install --save jade

在 express 4.x 中,您可以简单地将 设置view enginejade.

app.set('view engine', 'jade')
于 2014-06-21T05:16:26.120 回答