Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express 4 handlebars render without layout

Tags:

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?

like image 468
adrianvlupu Avatar asked May 26 '15 13:05

adrianvlupu


1 Answers

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

like image 141
Ryan Avatar answered Nov 03 '22 08:11

Ryan