Spaces between tags except at beginning nor end

Hello,

I want to output my taxonomy tags in a li tag as filter attributes as shown below:

<li data-filter="
{% for tag in p.taxonomy.tag %}
{{ tag }}
{% endfor %}
">

It outputs this, for example if two tags are defined:

<li data-filter="FaënceFaçade">

Is there a way to have spaces between tags, but not at the beginning nor the end in order to have something like this?

<li data-filter="Faënce Façade">

It might be very simple but I spent hours without finding a solution. Any clue or help would be so much appreciated.

@brigaill, Try the following:

{% set filter = p.taxonomy.tag|join(' ') %}
<li data-filter="{{ filter }}">

Thanks so much for your help @anon76427325 , you saved me a lot of time ! I try to learn twig but as I am not a developper, it’s quite hard for me.

Indeed It was that simple. I guess my mistake was trying with {% for tag in p.taxonomy.tag %} ? Because I tried the join filter, but it did not work in my code.

A post was split to a new topic: Hyphenise tags which contain spaces