我正在将我的应用程序从Express转换为sails.js - 有没有办法在Sails中做这样的事情?
从我app.js在Express中的文件:
var globals = {
name: 'projectName',
author: 'authorName'
};
app.get('/', function (req, res) {
globals.page_title = 'Home';
res.render('index', globals);
});
Run Code Online (Sandbox Code Playgroud)
这让我可以在每个视图上访问这些变量,而无需将它们硬编码到模板中.不知道在Sails中如何/在哪里做到这一点.