From f288b7aafaba379bfa97ba31e6f5fb620e10b4ed Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 19 Jun 2008 09:41:56 +0200 Subject: [PATCH] Documented differences of cycling between Django and Jinja2. --HG-- branch : trunk --- docs/switching.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/switching.rst b/docs/switching.rst index 0c49631..ba3cfb1 100644 --- a/docs/switching.rst +++ b/docs/switching.rst @@ -181,6 +181,27 @@ For loops work very similar to Django, the only incompatibility is that in Jinja2 the special variable for the loop context is called `loop` and not `forloop` like in Django. +Cycle +~~~~~ + +The ``{% cycle %}`` tag does not exist in Jinja because of it's implicit +nature. However you can achieve mostly the same by using the `cycle` +method on a loop object. + +The following Django template:: + + {% for user in users %} +
  • {{ user }}
  • + {% endfor %} + +Would look like this in Jinja:: + + {% for user in users %} +
  • {{ user }}
  • + {% endfor %} + +There is no equivalent of ``{% cycle ... as variable %}``. + Mako ---- -- 2.26.2