From: Kevin Boyd Date: Mon, 18 Mar 2013 06:18:20 +0000 (-0700) Subject: Adding a section about the slice filter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8ebbaaa4cc6197a96014681f2b7dd9bddd477585;p=web%2Fkonrad%2Ftwig.git Adding a section about the slice filter This code example shows how to loop over a subset of values in order to implement one common use-case of "break" in PHP. I decided to use the "full" notation of slice rather than the sugared version (that example would just be "for user in users[:10]") --- diff --git a/doc/tags/for.rst b/doc/tags/for.rst index 722861a..e39a59b 100644 --- a/doc/tags/for.rst +++ b/doc/tags/for.rst @@ -155,3 +155,17 @@ You can also access both keys and values:
  • {{ key }}: {{ user.username|e }}
  • {% endfor %} + +Iterating over Subset +--------------------- + +You might want to iterate over a subset of values. This can be achieved using the ``slice`` filter: + +.. code-block:: jinja + +

    Top Ten Members

    +