Template for loop, always creates line breaks

I have some automations that return a list of updates available.
When I use the template editor to check them, it always retuns line breaks, where I dont want them…it looks unclean

Is there a way to stop line breaks? Or is it normal?
This happens on multiple automations where I use a for loop to return human readable data.
Which is then sent as an automation.

{% set a = states.update 
  | selectattr('state','eq','on') 
  | map(attribute ='entity_id')
  | list
{% for state in a %}
{{ state_attr(state, 'friendly_name') }} v{{ state_attr(state, 'latest_version') }} available, running v{{ state_attr(state, 'installed_version') }}
{% endfor %}


Jinja uses various delimiters in the template strings.

{% %} - statements
{{ }} - expressions to print to the template output
{# #} - comments which are not included in the template output

Adding a - after a starting delimiter will remove previous whitespace.

Adding a - before an ending delimiter will remove trailing whitespace.

e.g. {%- removes leading whitespace before a statement -}} removes trailing whitespace after an expression that prints to the template output

1 Like

Perfect thanks, knew it would be something mega simple

adding in a - at the start of the {{ }} expression removes the line breaks