]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Fixes issue #77 by adding explanation to docs 104/head
authorNed Jackson Lovely <njl@njl.us>
Tue, 13 Mar 2012 00:45:08 +0000 (20:45 -0400)
committerNed Jackson Lovely <njl@njl.us>
Tue, 13 Mar 2012 00:45:08 +0000 (20:45 -0400)
Points out that the Django empty is replaced by the
Flask else.

docs/switching.rst

index ba3cfb1ff4f1c2aa34cceffb41107b54503c4c52..ee49df7ec8b0650c76057fa6c3db267df5c39895 100644 (file)
@@ -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
 ~~~~~