Formating a template in a script

Hello,

i tried to format my code output from my template, in the developer console its correkt but in the script its not okay.
I need the two outputs exactly one below the other so that the remote accepts the command as in this example

- home_hold
- select

this is my code

command: >
        {% set remote_command = remote_command  %} 
        {% set entities = remote_command.split(',') %} 
        {% if entities|length > 1 %}
        - {{ entities[0]  }}
        - {{ entities[1] }}
        {% else %}
        {{remote_command}}
        {% endif %}

there is everything alright but when i than save the code in the script he makes something like this

{% set remote_command = remote_command  %}  {% set entities =
        remote_command.split(',') %}  {% if entities|length > 1 %}  -
        {{entities[0] }}  - {{ entities[1] }} {% else %}  {{remote_command}}  {%
        endif %}

and the result is

-
        home_hold  - select

The format…

  - example 1
  - example 2

… denotes a list. You can likely just have your template render a list, you do not need it to keep the more human-readable format. Try the following:

      command: >
        {% set entities = remote_command.split(',') %} 
        {{ iif( entities | count ==1, entities | join, entities) }}

Hey, unfortunately it doesn’t work, according to Wiki and my test under Services it has to start with each other and with a hyphen

command:
   - home_hold
   - select
command: "{{ remote_command.split(',') }}"