Reputation:
I populate textarea with
textarea.value='{%for i in range(0,3)%}{{data[i][0]}}{% endfor %}'
.
But It produces string without spaces in between i
so the output is like
firstsecondthird
. I'd like it to be first second third
.
What are the ways to do it?
Upvotes: 2
Views: 15777
Reputation: 589
You need to do it outside the calculation part:
textarea.value='{%for i in range(0,3)%}{{data[i][0]}} {% endfor %}'
Notice the space after {{data[i][0]}}
Upvotes: 6
Reputation:
...it can be done by {%for i in range(0,3)%}{{data[i][0]+" "}}
As per Jinja documentation:
+
Adds two objects together. Usually the objects are numbers but if both are strings or lists you can concatenate them this way.
Upvotes: 4