for

Repeat content for each item in an array.

View Markdown

Syntax

{% for item in items %}...{% endfor %}

Usage

  • Use the name after for to access the current item. Close the block with endfor.
  • An empty or missing array produces no output.
  • Each item is separated by a line break. Leave an extra blank line before endfor to separate paragraphs or tables.

Loop values

  • loop.index is the current item number, starting at 1. loop.index0 starts at 0.
  • loop.first and loop.last are true for the first and last items.
  • loop.length is the total number of items.