By the end of this lesson, you should be able to...
<aside> 🚨 This video references material in the next lesson "Loops in Templates". It may be worth reading the material there before watching this video!
</aside>
Vid 1 - Generating different views via conditional statements in the Jinja2
template syntax
Vid 1 - Generating different views via conditional statements in the Jinja2
template syntax
Complete the exercise in this repl.it and submit your work.
<aside>
🤔 What if we need to render different views based on the context
values created by the user within the same route URL?
</aside>
The Jinja2
templating syntax supports conditional statements and can render different views depending on the values within the context
object passed to the template.
To utilize conditional statments in Jinja2
, the if statement must be wrapped in a single curly bracket and percent sign as follows: {% if/elif/else boolean expression %}
.