Created
April 10, 2017 14:54
-
-
Save RaidoS/716dd7ecdf0caa08bd5978f7214cef67 to your computer and use it in GitHub Desktop.
Django templates trick for comma separated lists, exclude "comming" last item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- template.html --> | |
{% for item in items %} | |
<a href="{{item.slug}}">{{item.name}}</a>{% include "comma.html" %} | |
{% endfor %} | |
<!-- comma.html --> | |
{% if not forloop.last %} | |
{% ifequal forloop.revcounter 2 %} и {% else %}, {% endifequal %} | |
{% else %} | |
{% endif %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment