From: Ned Jackson Lovely Date: Tue, 13 Mar 2012 00:45:08 +0000 (-0400) Subject: Fixes issue #77 by adding explanation to docs X-Git-Tag: 2.7~43^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7336b7af6c20a811930d49e97ef1bc447e062efa;p=thirdparty%2Fjinja.git Fixes issue #77 by adding explanation to docs Points out that the Django empty is replaced by the Flask else. --- diff --git a/docs/switching.rst b/docs/switching.rst index ba3cfb1f..ee49df7e 100644 --- a/docs/switching.rst +++ b/docs/switching.rst @@ -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 ~~~~~