How to write multiline text in automation

I wrote this automation to export a string like this

pippo#25#pluto36

into my log file.
It works perfectly, but since the original string is actually much longer, I would need to break it without inserting spaces.
This is the code of the given automation:

> text: >-
>     goofy"{{states('sensor.iphone13_battery_level')}}"pluto"{{states('sensor.energyapp_energy_power')}}"paperino"{{states('sensor.energyapp_energy_today')}}"
>   mode: single
> action: shell_command.log

A bit unclear to me what it is you want to do.

Insert linebreaks into the log message without inserting a linebreak? Don’t quite see how that would work. There are Unicode characters for “soft linebreaks” but no idea how widely supported they are in various viewers etc.

Insert linebreaks into the code/template without inserting linebreaks into its rendered output? You can use as much or as little whitespace within the Jinja markup/tags as you want, or you can add a dash to the beginning and/or end of a tag ({{-, -}}, {%-, -%}, {#- or -#}) to consume surrounding whitespace in the tag’s direction. See Whitespace Control in the documentation.

https://jinja.palletsprojects.com/en/stable/templates/#whitespace-control

Try using two line breaks like this (and don’t quote your mult-line templates):

 text: >
    goofy {{ states('sensor.iphone13_battery_level') }}
    
    pluto {{ states('sensor.energyapp_energy_power') }}
    
    paperino {{ states('sensor.energyapp_energy_today') }}

We’re almost there.
In reality I would also have to insert markers between the various elements
With this code:

data:
  text: >
    '#'pippo#{{states('sensor.iphone13_battery_level')}}'#'pluto#{{
    states('sensor.energyapp_energy_power')}}#paperino#{{ states('sensor.energyapp_energy_today') }}
  mode: single
action: shell_command.log

I got the following string:


2025-01-22#15:56:34#pippo50#pluto#302#paperino#5.983

And that’s fine.
Is there a more elegant way to write the code?
Thank you

Read the documentation. I already gave you the link and exactly which section to read.

If you use a marknown card, then you can use most HTML tags, including tables.

Thank you, very much :pray: