Passing a bash array as an environmental variable
nicoaws opened this issue · comments
Nicola Arnoldi commented
How would you pass a list/array argument to j2cli via the -e
option?
Adam Wojtczak commented
I've been using this and it is workaround, remember you can use Python syntax inside jinja2
:
Template:
{% set my_array = env_variable.split(',') %}
{% for item in my_array %}Item is : {{ item }}
{% endfor %}
Command: env_variable="1,2,3,4" j2 ./my_template.j2
Output:
Item is : 1
Item is : 2
Item is : 3
Item is : 4
Éric commented
That is not a bash array, but a regular string variable that contains comma-separated values.