Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a while ( x < y ) in jinja2

How should I do a while ( x < y ) in jinja2? I've seen the jinja2 docs, it seems like they only support for loop for a declared variable of array and while() is not supported at all.

like image 709
Gino Avatar asked Dec 02 '12 09:12

Gino


1 Answers

I think your closest alternative with Jinja2 would be to use a for with range:

  {% range number from 3 to 6 %}
      {{ number }}
      (...)
  {% endrange %}

And you can pass the variables from your program to use them in the loop.

like image 127
alemangui Avatar answered Oct 26 '22 13:10

alemangui