class documentation

class Cycler:

View In Hierarchy

Cycle through values by yield them one at a time, then restarting once the end is reached. Available as cycler in templates.

Similar to loop.cycle, but can be used outside loops or across multiple loops. For example, render a list of folders and files in a list, alternating giving them "odd" and "even" classes.

{% set row_class = cycler("odd", "even") %}
<ul class="browser">
{% for folder in folders %}
  <li class="folder {{ row_class.next() }}">{{ folder }}
{% endfor %}
{% for file in files %}
  <li class="file {{ row_class.next() }}">{{ file }}
{% endfor %}
</ul>
New in version 2.1.
Parameters
*itemsEach positional argument will be yielded in the order given for each cycle.
Method __init__ Undocumented
Method next Return the current item, then advance current to the next item.
Method reset Resets the current item to the first item.
Instance Variable items Undocumented
Instance Variable pos Undocumented
Property current Return the current item. Equivalent to the item that will be returned next time next is called.
def __init__(self, *items):

Undocumented

Parameters
*items:t.AnyUndocumented
def next(self):
Return the current item, then advance current to the next item.
Returns
t.AnyUndocumented
def reset(self):
Resets the current item to the first item.
items =

Undocumented

pos =

Undocumented

@property
current: t.Any =
Return the current item. Equivalent to the item that will be returned next time next is called.