.. include:: _include.rst
.. highlight:: html+jinja
.. _template_loops:
#####################
Loops
#####################
With loops you can iterate through the elements of a list.
.. _for_loop:
**********
For loop
**********
This example uses the ``for`` loop to iterate through the elements of the placeholder {{ FeaturesArray }}:
.. code::
{% for feautre in FeaturesArray %}
- {{ feature }}
{% endfor %}
Examples
--------
Image gallery
~~~~~~~~~~~~~~~~~~~
This example shows how to use the ``for`` loop to display all product images contained in the placeholder :ref:`placeholder_ImageSets`:
.. code::
{% if ImageSetsArray is not empty %}
Gallery
{% for imgSet in ImageSetsArray %}
{% endfor %}
{% endif %}
Note: The parameter ``rel="lightbox[{{ ASIN }}]"`` prepares the images for the use with lightbox plugins.
Three column design
~~~~~~~~~~~~~~~~~~~
This is an example of how to split an array into three parts and show the values in three columns. It uses |asa2|'s custom filter :ref:`filter_divide`.
.. code::
{% for part in FeaturesArray|divide(3) %}
{% for column in part %}
- {{ column }}
{% endfor %}
{% endfor %}