Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes issue pallets#77 by adding explanation to docs
Points out that the Django empty is replaced by the
Flask else.
  • Loading branch information
njl committed Mar 13, 2012
1 parent 8f0c8ee commit 7336b7a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions docs/switching.rst
Expand Up @@ -177,9 +177,25 @@ operator. Here are some examples::
Loops Loops
~~~~~ ~~~~~


For loops work very similar to Django, the only incompatibility is that in For loops work very similar to Django. Notably, in Jinja2 the special variable for
Jinja2 the special variable for the loop context is called `loop` and not the loop context is called `loop` and not `forloop` like in Django.
`forloop` like in Django.
In addition, the Django `empty` argument is called `else` in Jinja2. For example, the
Django template::

{% for item in items %}
{{item}}
{% empty %}
No items!
{% endfor %}

would be handled in Flask as::

{% for item in items %}
{{item}}
{% else %}
No items!
{% endfor %}


Cycle Cycle
~~~~~ ~~~~~
Expand Down

0 comments on commit 7336b7a

Please sign in to comment.