From the course: Building a Website with Node.js and Express.js

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Looping through lists in templates

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