What template system could I use to generate text fragments for all combination of input arrays?

Viewed 61

I have a 'template' that I wish to use to create potentially millions of text fragment, lets say this

Fragment {{loop1}}_{{loop2}}

Now, I define that the loop1 is from 1 to 3 and loop2 is from A to C. I want a template system to generate:

Fragment 1_A
Fragment 1_B
Fragment 1_C
Fragment 2_A
Fragment 2_B
...
Fragment 3_C

What should I use in this case?

1 Answers

with jinja2 you could play with something like this:

{% set loop1 = [1,2,3] %}
{% set loop2 = [A,B,C] %}
{% for i1 in loop1 %}
{% for i2 in loop2 %}
Fragment {{i1}}_{{i2}}
{% endfor %}
{% endfor %}
Related