So, Jinja -Lab 2 covers the use of
for loops WITHIN the template itself. Jinja provides for logic to be used within the template, so you can make decisions there with any data passed in to it.
In this example we aren’t actually using these
for loops to provide data into our template, what we’re doing is working with data that’s passed into the template. When we call the
render function, we’re creating a finalize output that allows us to pass in whatever data that template might require (in this case, the
interfaces list which is defined in the outer Python logic first), and we get an output that results from the logic that the Jinja template uses to process that data.
So, we always need a
render function to create some output from a template, and while we’re doing that, we also have the ability to pass data into the template for it to use in its internal logic. That’s why in this lab, we see
interfaces=interfaces. This is another way of saying "hey that list I defined in Python, please pass that into my template when you render it.
Hope that helps.