My Sails.js application have separate frontend
and admin
layout.
My view engine is ejs
.
How do I use separate layouts for frontend
Sorry for spamming your question but i need a similar solution for my app. It would be wonderful to define layouts in routes.js so for example /admin/* would use one layout, and eg. /app/* would use the other, etc. Because it's a pita do dive into controllers and overspam them with static layout paths. I tried this concept but it seems to be working only if I also define a controller in the routes.js config file eg:
module.exports.routes = {
'/admin/*' : {
controller: 'AdminController',
action: 'index',
locals: {
layout: 'admin/layout'
}
}
};
This does work, but is routing all actions for admin into the same controller, which is of course wrong. If I omit the controller part, that concept is always using the default view/layout.ejs and the local is not set:
module.exports.routes = {
'/admin/*' : {
locals: {
layout: 'admin/layout'
}
}
};
This doesn't work but it would be ideal to get it that way.