Hyphenise tags which contain spaces

Now I am trying to hyphenize tags which have spaces, but if I do this:

{% set filter = p.taxonomy.prestation|join(' ')|hyphenize %}{{ filter }}

it outputs hyphens even between tags as shown below:


Is there a solution to have hyphens only for tags, as following?

data-filter="sols placo peinture cuisine salle-de-bain"

I could not find out how to apply |hyphenize to tags only.

@brigaill, Try the following:

// default.md

  tag: [a, b, hyphenate me, c]
// Twig

{% set tags = [] %}

{# Step 1: Hyphenise each tag and add to array of tags #}
{% for tag in page.taxonomy.tag %}
    {% set hyphenisedTag = tag|hyphenize %}
    {% set tags = tags|merge([hyphenisedTag]) %}
{% endfor %}

{# Step 2: Join array of hyphenised tags #}
{% set filter = tags|join(' ') %}
<li data-filter="{{ filter }}"></li>
// Generated HTML

<li data-filter="a b hyphenate-me c"></li>

9 posts were split to a new topic: Hyphenize tags per page in collection