Answers.Body: <p>There's a couple of <a href="http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable">special variables</a> available while for looping through an array. In your case I'd make use of <a href="http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable"><code>loop.last</code></a>.</p>
  
  <pre><code>{{ tag }}{{ not loop.last ? ', ' }}
  </code></pre>
  
  <p>This is the expression using the <a href="http://twig.sensiolabs.org/doc/templates.html#other-operators">ternary operator</a> to keep the syntax short.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T09:46:54.683Z
Answers.Text: @noregt no love for the CSS solution?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T09:49:25.817Z
Answers.Text: Not really, if it's a list I'd also rather not have the separator in the html. (comma, backslash or similar)
Answers.UserDisplayName: noregt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T09:51:14.073Z
Answers.Text: That's the exact reason to use CSS over HTML, @noregt! You'd only apply the class to those inline lists you wanna STYLE like this.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T09:58:45.100Z
Answers.Text: I meant the LAST parsed separator, but I get your point if you're working with official lists. I was working with a simple paragraph line and comma's. But I admit that's not very good html.
Answers.UserDisplayName: noregt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T09:29:19.693Z
Answers.LastActivityDate: 2014-08-15T09:29:19.693Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>If you you have a given string and can't influence how it is generated, use the <a href="http://twig.sensiolabs.org/doc/filters/slice.html" rel="noreferrer"><code>slice</code></a> filter to crop that last comma:</p>
  
  <pre><code>{% set tags = 'Alpirsbacher Klosterbräu, Rothaus Tannenzäpfle, Neumarkter Lammsbräu, ' %}
  
  {# Remove the last two chars ", " from the string #}
  {{ tags|slice(0, -2) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T13:34:04.290Z
Answers.Text: Aha that's even better, so slice is the EE backspace alternative :-)
Answers.UserDisplayName: noregt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T13:35:25.520Z
Answers.Text: No, it's the worst way to do it in my opinion, @noregt!
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-16T08:33:42.503Z
Answers.Text: Haha I understand your annoyance, but essentially I wanted to know the alternative for the EE backspace parameter. You changed the title, but that was what I meant to ask.
Answers.UserDisplayName: noregt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-16T08:49:23.687Z
Answers.Text: Yep, I think the new title fits this Q/A better. You asked for a way to make your tag list and that EE thing was just a side note for me (yes, there are people using Craft NOT coming from EE :D). Cheers, @noregt.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-16T08:51:24.433Z
Answers.Text: Oh, and it's your question. Don't feel being pushed to accept the CSS solution! (but do it!!!)
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T13:32:15.817Z
Answers.LastActivityDate: 2014-08-15T13:32:15.817Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>What about using CSS for that?</p>
  
  <pre class="lang-css prettyprint-override"><code>.u-inlineList {
    display: inline;
  }
  
  .u-inlineList-item {
    display: inline;
    list-style: none;
  }
  
  .u-inlineList-item:after {
    content: ", ";
  }
  
  .u-inlineList-item:last-child:after {
    content: "";
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T09:20:00.970Z
Answers.Text: That is an option, but I would prefer if that can be done through craft. Or can't it?
Answers.UserDisplayName: noregt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T09:17:06.823Z
Answers.LastActivityDate: 2014-08-15T09:17:06.823Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>An alternative, if you are getting the tags from the <a href="http://buildwithcraft.com/docs/tags-fields">Tag Field</a> type, is the <a href="http://twig.sensiolabs.org/doc/filters/join.html">Join</a> filter:</p>
  
  <pre><code>{% if post.tags | length %}
      Tags: {{ post.tags | join(', ') }}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-18T16:41:27.700Z
Answers.Text: Very clever and simple, ideal for tags :-)
Answers.UserDisplayName: noregt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-13T19:52:18.643Z
Answers.Text: Worked perfectly. Thank you!
Answers.UserDisplayName: Anna_MediaGirl
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T19:42:24.950Z
Answers.LastActivityDate: 2014-11-19T19:42:24.950Z
Answers.UserDisplayName: mattl
Body: <p>In a list of tags I'd like to remove the last comma. So is there something that works like the Ee backspace parameter?</p>
  
Tags: <templating><tags><conditional><forloop>
Title: Remove the last comma in an inline list of tags?
ThreadText: # Remove the last comma in an inline list of tags?
  
  (Asked by: username_0 on 2014-08-15)
  
  In a list of tags I'd like to remove the last comma. So is there something that works like the Ee backspace parameter?
  
  **Tags:** templating, tags, conditional, forloop
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_2 on 2014-11-19. Score: 10 | Accepted answer
  
  An alternative, if you are getting the tags from the [Tag Field](http://buildwithcraft.com/docs/tags-fields) type, is the [Join](http://twig.sensiolabs.org/doc/filters/join.html) filter:
  
  ```
  {% if post.tags | length %}
      Tags: {{ post.tags | join(', ') }}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Very clever and simple, ideal for tags :-)  
  > **username_3**: Worked perfectly. Thank you!  
  
  ---
  
  ### Answer by username_1 on 2014-08-15. Score: 18
  
  There's a couple of [special variables](http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable) available while for looping through an array. In your case I'd make use of [`loop.last`](http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable).
  
  ```
  {{ tag }}{{ not loop.last ? ', ' }}
  
  ```
  
  This is the expression using the [ternary operator](http://twig.sensiolabs.org/doc/templates.html#other-operators) to keep the syntax short.
  
  > **Comments:**
  > **username_1**: @username_0 no love for the CSS solution?  
  > **username_0**: Not really, if it's a list I'd also rather not have the separator in the html. (comma, backslash or similar)  
  > **username_1**: That's the exact reason to use CSS over HTML, @username_0! You'd only apply the class to those inline lists you wanna STYLE like this.  
  > **username_0**: I meant the LAST parsed separator, but I get your point if you're working with official lists. I was working with a simple paragraph line and comma's. But I admit that's not very good html.  
  
  ---
  
  ### Answer by username_1 on 2014-08-15. Score: 5
  
  If you you have a given string and can't influence how it is generated, use the [`slice`](http://twig.sensiolabs.org/doc/filters/slice.html) filter to crop that last comma:
  
  ```
  {% set tags = 'Alpirsbacher Klosterbräu, Rothaus Tannenzäpfle, Neumarkter Lammsbräu, ' %}
  
  {# Remove the last two chars ", " from the string #}
  {{ tags|slice(0, -2) }}
  
  ```
  
  > **Comments:**
  > **username_0**: Aha that's even better, so slice is the EE backspace alternative :-)  
  > **username_1**: No, it's the worst way to do it in my opinion, @username_0!  
  > **username_0**: Haha I understand your annoyance, but essentially I wanted to know the alternative for the EE backspace parameter. You changed the title, but that was what I meant to ask.  
  > **username_1**: Yep, I think the new title fits this Q/A better. You asked for a way to make your tag list and that EE thing was just a side note for me (yes, there are people using Craft NOT coming from EE :D). Cheers, @username_0.  
  > **username_1**: Oh, and it's your question. Don't feel being pushed to accept the CSS solution! (but do it!!!)  
  
  ---
  
  ### Answer by username_1 on 2014-08-15. Score: 3
  
  What about using CSS for that?
  
  ```css
  .u-inlineList {
    display: inline;
  }
  
  .u-inlineList-item {
    display: inline;
    list-style: none;
  }
  
  .u-inlineList-item:after {
    content: ", ";
  }
  
  .u-inlineList-item:last-child:after {
    content: "";
  }
  
  ```
  
  > **Comments:**
  > **username_0**: That is an option, but I would prefer if that can be done through craft. Or can't it?  
  
  ---
  
  