即使布局设置为True,快速Jade布局也不会呈现

我是Express for Node.js的新手,我刚刚按照Pedro Teixeira的Node Tuts Episode 9设置了一个简单的应用程序。 我想试验布局文件,所以我把布局设置为“真实”。 当我这样做的时候,它没有用我的布局渲染,只用我的身体渲染。 我应该怎样才能正确渲染? 下面是我的app.js文件,我的index.jade,我的layout.jade,和我的渲染页面的屏幕截图。

app.js

var express = require('express'); var app = express.createServer(); app.configure(function () { app.use(express.logger(); }); app.set('views', __dirname + '/views'); app.set('view engine','jade'); app.set('view options', {layout: true}); app.get('/', function(request, response) { response.render('index'); }); app.listen(4000); 

index.jade

 h2 Hello p World! 

layout.jade

 !!! 5 html head title My template body #main h1 Content goes here p Testing 123 #container!= body 

如果您使用的是Express 3,则模板渲染的方式已经改变。

您的布局需要如下所示:

 !!! 5 html head title My template body #main h1 Content goes here p Testing 123 block content 

而你的模板:

 extends layout block content h1 Something 

这里的例子:

https://github.com/dotcloud/express-on-dotcloud/blob/master/app/views/layout.jade#L64

https://github.com/dotcloud/express-on-dotcloud/blob/master/app/views/welcome.jade#L1

如果你从Node和Express开始,随时克隆这个演示/教程的应用程序:
https://github.com/dotcloud/express-on-dotcloud

你可以用它来欺骗它,并发现Express 3的一些不错的function,如果你想分享你的应用程序,所有的设置都会被推送到dotCloud 。