Simple Lists With Less

Ever need to make a list of comma separated values but always have that last "," at the end?

Here's some code I've been reusing for a while, including on this blog.

LESS

.tags {
  margin-bottom: 0px;

span + span { &:before { content: ", " } } }



HTML

<div class="tags"> 
  {% for tag in post.tags.all %}<span>{{ tag }}</span>{% endfor %}
</div>

Tags:lesscssfrontend

Posted:Oct. 27, 2013, 4:54 p.m.

comments powered by Disqus