I have a website in node.js; to create a page, say mypage I noticed I need to create both a layout.jade and mypage.jade files. If I put code in mypage.jade it is not displayed, so first I have to fill layout.jade with the layout of the page.
My question is, how do I reference inside layout.jade that I would like to load the content of mypage.jade in a certain container, for example? Can I have different pages with the same layout? How can I do this?
Thanks
http://expressjs.com/guide.html#view-rendering
If you don’t want to use layouts you can disable them globally:
If you don’t do that layouts are enabled by default and Express searches for the standard layout in your_view_folder/layout.jade
You can specify a separate layout for each route though:
Here’s how your layout file could be:
Note that body will be taken from “mypage.jade”.
Edit:
Here’s a real example in an application:
The application file (containing routes and configs):
https://github.com/alexyoung/nodepad/blob/master/app.js
The layout file:
https://github.com/alexyoung/nodepad/blob/master/views/layout.jade