Is there a way in an express 4 app to render a view without using a layout?
I have a layout.hbs inside the project. The file seems to be used without needing to register it anywhere and for most views that is ok, but what if just a single view needs to be rendered without?
Assuming you are using express-handlebars you can specify a different layout from your route/controller when you call the render method. To get rid of the layout altogether you can set the layout to false
.
router.get('/', function(req, res) { res.render('home', {layout: false}); });
https://github.com/ericf/express-handlebars#layouts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With