From 4aa97f5c18f1242d4ef33931cf7567f997f24a6f Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 24 Nov 2008 22:01:48 +0000 Subject: Fixed #6398: added an optional `{% empty %}` clause to the `{% for %}` template tag. The contents of this clause are rendered if the list iterated over turns out to be empty. Thanks, Jannis Leidel. Astute readers will notice that the patch originally called this `default`; after consideration I decided that `empty` is a very slightly better color for this particular bikeshed. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9530 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/templates/builtins.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'docs') diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index a14f50adf0..f67f1a86cd 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -234,6 +234,35 @@ The for loop sets a number of variables available within the loop: current one ========================== ================================================ +for ... empty +^^^^^^^^^^^^^ + +.. versionadded:: 1.1 + +The ``for`` tag can take an optional ``{% empty %}`` clause that will be +displayed if the given array is empty or could not be found:: + +