From: Christoph Zwerschke Date: Wed, 21 Mar 2012 15:56:36 +0000 (+0100) Subject: Add a note about the else statement. X-Git-Tag: 2.7~37^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4780c2ce31e9701cd60e227fee83a20cea8b7a8f;p=thirdparty%2Fjinja.git Add a note about the else statement. --- diff --git a/docs/templates.rst b/docs/templates.rst index a21e3310..4a145c13 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -571,6 +571,10 @@ by using `else`:: {% endfor %} +Note that in Python `else` blocks are executed whenever the corresponding +loop did not `break`. Since in Jinja loops cannot `break` anyway, +a slightly different behavior of the `else` keyword was chosen. + It is also possible to use loops recursively. This is useful if you are dealing with recursive data such as sitemaps. To use loops recursively you basically have to add the `recursive` modifier to the loop definition and