Reputation: 113
I'm using jinja2 to template a supercollider startup file.
I have a variable {{ sc_option_numOutputBusChannels }}
from which I need to generate a list.
Specifically, if sc_option_numOutputBusChannels = 8
, then I need to create the following list:
[0, 2, 4, 6]
for use in the line:
~dirt.start(57120, [0, 2, 4, 6]);
The function range(0, sc_option_numOutputBusChannels, 2 )
outputs that list exactly as I need it, but I've been unable to find a way to use the output of range
directly as a string in my template - eg these don't work:
~dirt.start(57120, {% range(0, sc_option_numOutputBusChannels, 2 ) %} );
~dirt.start(57120, {{ range(0, sc_option_numOutputBusChannels, 2 ) }} );
Is there a way to do this?
Upvotes: 0
Views: 784
Reputation: 33203
I would guess it is because range
by itself is a generator, and thus needs a consumer to indicate to ansible that you're done with the generator pipeline; the most common one I know of is | list
- debug:
msg: ~dirt.start(57120, {{ range(0, sc_option_numOutputBusChannels, 2 ) | list }} );
Upvotes: 3