Join Daniel Khan for an in-depth discussion in this video Using includes to factor out content, part of Building a Website with Node.js and Express.js.
- [Narrator] So from a layout file,…I now want to vector out some parts…and let's look at the page real quick.…And if we use Inspect of Chrome Developer Tools,…we can easily look at the different elements…this page consists of, and you see that…there is a header section that contains…this big picture and also the navigation below.…
And I want to factor out this section now…into a new file header and for that I…first create a new folder include…inside the layout directory so there should…be all includes of the layout template,…and in there I create a new file header.pug.…And now I will grab the header and scroll down all the way.…
I cut this out and paste it into header.pug.…And I of course have to fix the indents again…so I'm using shift out, over down my mouse…all the way and remove that indentation…and next in my layout template…I will now include, includes/header.…
Let's try that out, and this works so far.…Let's see what happens if I now remove the, includes…so let's make the test that this is really…working as expected, and we see that our…
- Creating a server with Express and pure Node.js
- Handling errors in Express
- Creating routes
- Using templates
- Working with the Pug template engine
- Implementing the site structure and logic
- Working with conditionals
- Dealing with POST requests
- Sanitizing user inputs and handling form errors
Skill Level Beginner
What you should know1m 40s
1. Getting Started
2. Express Basics
3. Getting Started with Our Project
4. Getting Started with Templates
5. Implementing the Site Structure and Logic
6. Handling Form Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.