Bootstrap FreeKB - Jinja - Getting Started with Lists
Jinja - Getting Started with Lists

Updated:   |  Jinja articles

Here is a basic example of how to create and print a list in Jinja.

{% set fruits=['apple','banana','grape','orange'] %}
{% print fruits %}

 

And here is a basic example of how to loop over a list of values in Jinja.

{% set fruits=['apple','banana','grape','orange'] %}

{% for fruit in fruits %}
{{ fruit }}
{% endfor %}

 

Or, you can print a specific index item from the list. In this example, index item 0 (apple) will be printed.

{% set fruits=['apple','banana','grape','orange'] %}

{% for fruit in fruits %}
{{ fruit[0] }}
{% endfor %}



Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter b8d671 in the box below so that we can be sure you are a human.