I had this line in my Jinja2 template:
{% for type in types %}
top -> {{(loop.index0 + 'a')|string}}(var{{loop.index0}});
{% endfor %}
where types is a list of various types in C++ that is used elsewhere in the template and the output is part of a SystemC program to initialize module signals. The goal is to get an output like this with characters starting from lowercase a:
top -> a(var0);
top -> b(var1);
However, it was giving this error: "unsupported operand type(s) for +: 'int' and 'str'" so I tried changing the template to this:
{% for type in types %}
top -> {{(loop.index0 + 'a'|int)|string}}(var{{loop.index0}});
{% endfor %}
but then the output was this
top -> 0(var0);
top -> 1(var1);
It seems that the issue is that there is no way to convert from an integer to its corresponding ASCII character within the Jinja2 template. I tried "chr()" but that is a Python function and not a Jinja2 one and doesn't work. I was wondering if there is anyone who has had experience with this and could help me out?