Join Daniel Khan for an in-depth discussion in this video Working with template variables, part of Building a Website with Node.js and Express.js.
- [Narrator] Naturally, dynamic data…should not be stored in the template…but should provide it to the template.…In expressed a few ways, how to make…data available to a template.…There are variables that are set…when the application starts up…and there are others that are…globally valid for a given request.…And then there are variables at…a specific tour route or template.…We will start by defining a global…template variable that contains…the name of our page.…We will use it in some of our templates,…so I open server, index js.…
And there our set before the route starts…so line 14 is a good place for that.…App dot locals dot title.…So this is now a variable that is valid…for the whole application…and this should be config dot sitename…as we said it before.…Of course, now we also have to change…the templates for that.…So I go into fuse and first, in layout…index pug, let's look for the title.…
And there I will replace the current title…with equals title.…Looking at the page, I also see that…the title is here on the navigation.…
- 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.