From the course: Building a Website with Node.js and Express.js
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Looping through lists in templates
From the course: Building a Website with Node.js and Express.js
Looping through lists in templates
- [Instructor] By now we have the list of speaker names that we fetch with every request and store into a template variable. Let's see how we can now render the navigation from it. For that, I open views, layout, partials, and there, navigation ejs. You now already see how much easier things get once the layout has been split into logical parts, because now I am right in my navigation, and just scroll down until I find this dropdown. It starts at line 29, and there I see that the individual speaker starts with line 33. And what I will do now is, I separate this out first by adding blank lines. And I will remove this Lorenzo Garcia entry, and also the last entry for Mr.Rewington, and just leave Hillary Goldwynn in here. We use that entry more or less as a blueprint for the dynamic data that we want to render out now. Next, I want to now loop through the speaker names template variable. And for that, I first add the…
Contents
-
-
-
-
-
-
(Locked)
Create a site-wide layout6m 54s
-
(Locked)
Using partials with EJS4m 56s
-
(Locked)
Template variables in more detail5m 57s
-
(Locked)
Looping through lists in templates11m 33s
-
(Locked)
Creating a list page6m 4s
-
(Locked)
Using parameter routes7m 9s
-
(Locked)
Challenge: Partials and lists2m 20s
-
(Locked)
Solution: Partials and lists8m 46s
-
(Locked)
-
-
-
-