<pre><code>{% for type in entry.buildType %}
{{ type }}
{% if not loop.last %}/{% endif %}
{% endfor %}
</code></pre>

<p>See: <a href="https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable" rel="nofollow noreferrer">https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable</a></p>

CC BY-SA 4.0
2018-07-23T06:32:23.483Z
2018-07-23T06:52:09.647Z
2018-07-23T06:52:09.647Z
Luke Holder
<p>I need to add a separator if there are a multiple of types. How can this be done in a for loop? </p>

<pre><code>{% for type in entry.buildType %}{{ type }}{% endfor %}
</code></pre>

<p>The outcome is similar to a breadcrumb nav, with an added "/", however the separator should only be placed in between - not for the last.</p>

CC BY-SA 4.0
2018-07-23T10:29:31.180Z
Twig also has a very useful [join filter](https://twig.symfony.com/doc/2.x/filters/join.html), which does exactly this.
Jamie Wade
<conditional><forloop>
Add conditional in a for loop
# Add conditional in a for loop

(Asked by: username_0 on 2018-07-23)

I need to add a separator if there are a multiple of types. How can this be done in a for loop? 
{% for type in entry.buildType %}{{ type }}{% endfor %}

The outcome is similar to a breadcrumb nav, with an added "/", however the separator should only be placed in between - not for the last.

**Tags:** conditional, forloop
> **Comments:**
> **username_1**: Twig also has a very useful [join filter](https://twig.symfony.com/doc/2.x/filters/join.html), which does exactly this.  

---

## 1 answers

### Answer by username_2 on 2018-07-23. Score: 3 | Accepted answer

{% for type in entry.buildType %}
{{ type }}
{% if not loop.last %}/{% endif %}
{% endfor %}

See: https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable


---

