Template Creating Line Breaks Issue

I’m using the a template (found somewhere online but can’t give credit as I can’t remember where…so apologies to the creator) in a markdown card but in the resulting list it’s creating a blank row below each entity.

I don’t know enough about templates to identify if any part of the code is creating the spacing so I was hoping someone could please help?

Below is the template, the resulting list and an example of how I would expect to see it taken from another markdown card template I have:

Template

{% set device_ids = states
  | selectattr('state', 'in', ['unavailable', 'unknown'])
  | map(attribute='entity_id')
  | map("device_id")
  | map("string")
  | unique
  | select("ne", "None")
  | list
%}
{% for device_id in device_ids %}
  {{ device_attr(device_id, "name_by_user") or device_attr(device_id, "name") }}
{% endfor %}

Result

Screenshot 2023-05-22 at 18.14.05

Example of expected result

Screenshot 2023-05-22 at 18.14.26

Add a hyphen as shown here:

{%- endfor %}

Google “Jinja2 whitespace control”

1 Like

The resolved it. Thank you.

1 Like