【发布时间】:2010-08-30 14:07:11
【问题描述】:
我有一个基本的 Express 服务器:
// server.js:
var Express = require('express');
app = Express.createServer();
app.configure(function(){
app.set('views', Path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.set('view options');
});
app.get('/', function (request, response) {
response.render('welcome', {
locals: {some: 'Locals'}
});
});
有一个基本的玉器布局:
// views/layout.jade:
!!! 5
html(lang='en')
head
title= pageTitle
body
h1= pageTitle
aside(id="sidebar")= sidebarContent
#content
#{body}
还有一个简单的页面:
# views/welcome.jade:
// How do I pass pageTitle and sidebarContent out to the layout from here?
p
Welcome to my fine site!
(在 Rails 中,这可能类似于 content_for 或简单的实例变量。)
【问题讨论】:
-
虽然它是基于 DocPad 的 cms,但您可能会发现它很有用,因为它内置了对布局和玉石的支持。 github.com/balupton/docpad
标签: javascript node.js pug