Flask Jinja2 Template Does Not Display CONTINUE Statement

I am trying a simple continue inside for-loop in Flask with jinja2

 {% for num in range(0,10) %} {% if num%2 == 0 %} {% print num %} {% else %} {% continue %} {% endif %} 

and i get this error

TemplateSyntaxError: Encountered unknown tag 'continue'. Jinja was looking for the following tags: 'endif'. The innermost block that needs to be closed is 'if'.

Here is the jinja2 documentation I followed ... http://jinja.pocoo.org/docs/templates/#loop-controls

+6
source share
1 answer

You need to add the extension to control Jinja 2 in your application:

 app.jinja_env.add_extension('jinja2.ext.loopcontrols') 
+18
source

Source: https://habr.com/ru/post/945209/


All Articles