【发布时间】:2017-08-02 12:25:34
【问题描述】:
我希望在渲染时将参数传递给我的 Stylus 文件。因此,例如在我的 app.js 文件中,我有:
app.get('/myPage', function(req, res) {res.render('myPageTemplate', { title:
'MyPageTitle' , myColor: '#E3D'});});
app.get('/myPage2', function(req, res) {res.render('myPageTemplate', { title:
'MyPage2Title' , myColor: '#0FF'});});
显然我可以在我的 ejs 文件中访问这些参数,例如
<title><%= title%></title>
在我的 Stylus 文件中,我希望能够执行以下操作:
div{
background-color: <%=myColor%>;
}
这是可能的还是我走错了路? 感谢您的帮助!
【问题讨论】: