CH06
CH06

Reputation: 167

How to add two spaces after split?

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

Answers (2)

CH06
CH06

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

vivekpadia70
vivekpadia70

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

Related Questions