From 46eccb9ab56355cd7c7b4de1a39fdd94232260d3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 6 Aug 2011 08:40:52 +0200 Subject: [PATCH] added documentation for previous merge --- CHANGELOG | 2 +- doc/templates.rst | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9f596b4..81bb39c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.2.0 -n/a + * added "if" modifier support to "for" loops * 1.1.2 (2011-07-30) diff --git a/doc/templates.rst b/doc/templates.rst index 96699b4..f977026 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -568,9 +568,23 @@ Variable Description ``loop.last`` variables are only available for PHP arrays, or objects that implement the ``Countable`` interface. -.. note:: +.. versionadded:: 1.2 + The ``if`` modifier support has been added in Twig 1.2. + +Unlike in PHP, it's not possible to ``break`` or ``continue`` in a loop. You +can however filter the sequence during iteration which allows you to skip +items. The following example skips all the users which are not active: + +.. code-block:: jinja + + - Unlike in PHP it's not possible to ``break`` or ``continue`` in a loop. +The advantage is that the special loop variable will count correctly thus not +counting the users not iterated over. If no iteration took place because the sequence was empty, you can render a replacement block by using ``else``: -- 1.7.2.5