How does the 'with' statement work in Flask (Jinja2)?
{% with %}
statement in Jinja lets you define variable, but limits the scope of a variable with the {% endwith %}
statement. For example :
{% with myvar=1 %}
...
{% endwith %}
Any elements declared in the body will have access to the myvar variable.
Please, refer - https://www.webforefront.com/django/usebuiltinjinjastatements.html
The with
statement in Flask is not the same as the with
statement in Python.
Within python the equivalent would be this:
messages = get_flashed_messages()