I am reading my stylesheet file and storing it in a variable which I would then like to pass in to my EJS template as the styles for that page.
This is what I have in server.js file:
function getRenderVariables (req) {
const MY_CSS = fs.readFileSync(path.resolve(__dirname, './css/my-css.css'), 'utf8')
return {
MY_CSS
}
}
app.get('/mypage', (req, res) => {
res.render('index', getRenderVariables(req))
})
For the record, the MY_CSS variable is appropriately reading the file and it's value as its being passed in, is what I expected. In mypage.ejs I would like to use the styles from the loaded stylesheet. How do I do that?
<div class="some-class">
<style>
// Not working! How can I do this?
<%= MY_CSS %>
</style>
<div>
Other stuff....
</div>
</div>