Permalink
Browse files

Fix #77 by adding note to switching document

Explaining that {% empty %} in Django loops is {% else %} in Jinja2.
  • Loading branch information...
1 parent 7fe70fd commit 37bcc69364b51264c51c6a0163fad4dd3bc9d911 @njl njl committed Mar 12, 2012
Showing with 19 additions and 3 deletions.
  1. +19 −3 docs/switching.rst
View
@@ -177,9 +177,25 @@ operator. Here are some examples::
Loops
~~~~~
-For loops work very similar to Django, the only incompatibility is that in
-Jinja2 the special variable for the loop context is called `loop` and not
-`forloop` like in Django.
+For loops work very similar to Django. Notably, in Jinja2 the special variable for
+the loop context is called `loop` and not `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
~~~~~

0 comments on commit 37bcc69

Please sign in to comment.