express-ejs-layouts
express-ejs-layouts copied to clipboard
Cryptic error message
Setting up a simple example project:
//...
app.set('view engine', 'ejs');
app.set('views', __dirname + '/views');
app.set('layout', __dirname + '/views/layouts/default.ejs');
app.set('layout extractScript', true);
app.set('layout extractStyles', true);
//...
When rendering a simple page, I was getting 'script' is not defined (Referring to <%- script %>
in the layout file)
I found that the issue was that I set 'extractScript'
, and not 'extractScripts
', but the error message is very cryptic for newcomers. Shouldn't it be something like:
"you need to set 'layout extractScripts' to true before using <%- script %>"
Not critical by any means, but it took me a while to find the typo. It would be nice to get that half an hour of my life back.