Tôi đang sử dụng node.js
với hệ thống templating Jade
.Biến toàn cục cho các mẫu Jade trong node.js
Giả sử, tôi có những quy tắc định tuyến:
// ./routes/first.js
exports.first = function(req, res)
{
res.render('first', {
author: 'Edward',
title: 'First page'
});
};
// ./routes/second.js
exports.second = function(req, res)
{
res.render('second', {
author: 'Edward',
title: 'Second page'
});
};
Và những quan điểm giả:
// ./views/first.jade
html
head
title #{author} – #{title}
body
span First page content
// ./views/second.jade
html
head
title #{author} – #{title}
body
span Second page content
Làm thế nào tôi có thể tuyên bố author
biến nói chung, đối với cả hai quan điểm?
Duplicate của http://stackoverflow.com/questions/4718818/express-js-view-globals –