kolypto / j2cli

Jinja2 Command-Line Tool, reworked

Home Page:http://pypi.python.org/pypi/j2cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing a bash array as an environmental variable

nicoaws opened this issue · comments

How would you pass a list/array argument to j2cli via the -e option?

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
commented

That is not a bash array, but a regular string variable that contains comma-separated values.