layout.ejs未呈现 – Node.js,Express

我想用EJS模板执行一个简单的node.js例子。 节点,或者更确切地说,无论我做什么,都无法使用layout.ejs呈现索引页,如下面的代码所示。

这是app.js

var express = require('express') , routes = require('./routes') , http = require('http'); var app = express(); app.configure(function(){ app.set('port', process.env.PORT || 8001); app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); app.set('view options', {layout: 'views/layout.ejs'}); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(__dirname + '/public')); }); app.configure('development', function(){ app.use(express.errorHandler()); }); app.get('/', routes.index); http.createServer(app).listen(app.get('port'), function(){ console.log("Express server listening on port " + app.get('port')); }); 

layout.ejs

 <!DOCTYPE html> <html> <head> <title><%= title %></title> </head> <body> <%- body %> </body> </html> 

而在index.ejs中,就是这样

 <p> Some Text </p> 

我在这里错过了什么吗?

       

网上收集的解决方案 "layout.ejs未呈现 – Node.js,Express"