Reputation: 167
On my code:
params:
"- key: fruits|value: apples, - key: travel_by|value: truck "
{% for elements in params.split(",") %}
{% for line in elements.split("|") %}
{{ line }}
{% endfor %}
{% endfor %}
I have this undesired result:
- key: fruits
value: apples
- key: travel_by
value: truck
Because I search the method to add 2 spaces " " before "value:..." after the split.
Upvotes: 1
Views: 49
Reputation: 167
I found:
I added 2 spaces after "|" on the data structure.
params:
"- key: fruits| value: apples, - key: travel_by|value: truck "
With this, the second split cut the phrase with the "|" synbol in two parts and the second part start with 2 spaces for the correct identation.
Upvotes: 0
Reputation: 1095
You can add spaces like this
{{ " " + line }}
OR
{{ "\t" + line }}
As per the documentation:
- Adds two objects together. Usually the objects are numbers but if both are strings or lists you can concatenate them this way.
Upvotes: 1