I am looking to pass a parameter to my Stylus file when it is being rendered. So for example in my app.js file I have:
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'});});
Obviously I can access these parameters in my ejs files e.g.
<title><%= title%></title>
In my Stylus file I would like to be able to do something like:
div{
background-color: <%=myColor%>;
}
Is this possible or am I going about this the wrong way? Thanks for your help!
This is really a bad idea as most of the reverse proxies (if you are using one like cloudflare) cache your css and also it sets the Cache-Control headers so that browsers can cache it. So you will not get your desired behaviour.
Instead doing what you are doing now, you can create multiple css classes and add those classes to your div in .ejs file based on conditions.