Jinja - Convert string to list using split

by
Jeremy Canfield |
Updated: May 25 2024
| Jinja articles
split can be used to convert a string into a list.
{% set fruit='apple','banana','grape','orange' %}
{% set fruits = fruit.split(',') %}
{% for item in fruits %}
{{ item }}
{% endfor %}
Did you find this article helpful?
If so, consider buying me a coffee over at