Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
Created October 18, 2019 21:10
Show Gist options
  • Save rms1000watt/feb6da2bf29c415246f62fa2508bd808 to your computer and use it in GitHub Desktop.
Save rms1000watt/feb6da2bf29c415246f62fa2508bd808 to your computer and use it in GitHub Desktop.
Jinja2 omit comma from last item in list
# Courtesy of: https://stackoverflow.com/a/11974399
{%- for item in items %}
[
"{{item}}"{{ "," if not loop.last }}
]
{%- endfor %}
@vsmychyk
Copy link

Thank you for this solution!

@t-prinz
Copy link

t-prinz commented Sep 22, 2022

Agreed!

@svkrclg
Copy link

svkrclg commented Oct 6, 2022

neat and clean solution

@dischello
Copy link

Does not work with dicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment