j2cli icon indicating copy to clipboard operation
j2cli copied to clipboard

Passing a bash array as an environmental variable

Open nicoaws opened this issue 4 years ago • 3 comments

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

nicoaws avatar Apr 22 '20 07:04 nicoaws

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

adamwojt avatar May 21 '20 15:05 adamwojt

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

merwok avatar Oct 20 '20 15:10 merwok

Hi! This project gets some interest, but sadly, I'm not maintaining it =\

Maintainer wanted! Discussion: Maintainer Wanted

kolypto avatar Feb 10 '24 16:02 kolypto