Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixes issue #77 by adding explanation to docs

Points out that the Django empty is replaced by the
Flask else.
  • Loading branch information...
commit 7336b7af6c20a811930d49e97ef1bc447e062efa 1 parent 8f0c8ee
Ned Jackson Lovely authored

Showing 1 changed file with 19 additions and 3 deletions. Show diff stats Hide diff stats

  1. +19 3 docs/switching.rst
22 docs/switching.rst
Source Rendered
@@ -177,9 +177,25 @@ operator. Here are some examples::
177 177 Loops
178 178 ~~~~~
179 179
180   -For loops work very similar to Django, the only incompatibility is that in
181   -Jinja2 the special variable for the loop context is called `loop` and not
182   -`forloop` like in Django.
  180 +For loops work very similar to Django. Notably, in Jinja2 the special variable for
  181 +the loop context is called `loop` and not `forloop` like in Django.
  182 +
  183 +In addition, the Django `empty` argument is called `else` in Jinja2. For example, the
  184 +Django template::
  185 +
  186 + {% for item in items %}
  187 + {{item}}
  188 + {% empty %}
  189 + No items!
  190 + {% endfor %}
  191 +
  192 +would be handled in Flask as::
  193 +
  194 + {% for item in items %}
  195 + {{item}}
  196 + {% else %}
  197 + No items!
  198 + {% endfor %}
183 199
184 200 Cycle
185 201 ~~~~~

0 comments on commit 7336b7a

Please sign in to comment.
Something went wrong with that request. Please try again.