From acce36cedeae9f8b361f9eca0d61375a3a153ed4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 18 Aug 2025 12:05:39 +0200 Subject: [PATCH] Add missing documentation about for loop features --- book/src/template_syntax.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/book/src/template_syntax.md b/book/src/template_syntax.md index 648d705a..3221431e 100644 --- a/book/src/template_syntax.md +++ b/book/src/template_syntax.md @@ -466,7 +466,33 @@ Loop over each item in an iterator. For example:

Users

+``` + +You can filter items by adding an `if` condition: + +```jinja +

Users

+ +``` + +You can add an optional `{% else %}` block that is entered if the loop was never +entered, either because the iterator was empty, or the filter condition was never +match. + +```jinja +

Users

+ ``` @@ -478,7 +504,6 @@ Inside for-loop blocks, some useful variables are accessible: * *loop.first*: whether this is the first iteration of the loop * *loop.last*: whether this is the last iteration of the loop - ```jinja

Users