Skip to content

As rows in a table

This example uses the YAML in _yaml/large-example.yml. Refer to External YAML files for guidance on including YAML files.

Code

| Name | Color | Sweetness |
| ---- | ------ | --------- |
{% for fruit in fruits %}| {{ fruit.name }} | {{ fruit.color }} | {{ fruit.sweetness }} |
{% endfor %}

Output

Name Color Sweetness
apple green 4/10
orange orange 6/10
melon yellow 8/10

Note the positioning of the for syntax in the code example. This is deliberate. The following don't work:

| Name | Color | Sweetness |
| ---- | ------ | --------- |
{% for fruit in fruits %}
| {{ fruit.name }} | {{ fruit.color }} | {{ fruit.sweetness }} |
{% endfor %}

| Name | Colour | Sweetness |
| ---- | ------ | --------- |
{% for fruit in fruits %}| {{ fruit.name }} | {{ fruit.colour }} | {{ fruit.sweetness }} |{% endfor %}