Skip to content

Instantly share code, notes, and snippets.

@hyperking
Created September 20, 2013 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyperking/6642615 to your computer and use it in GitHub Desktop.
Save hyperking/6642615 to your computer and use it in GitHub Desktop.
Split Key Value Pairs multiple times using jinja template
{% if article.productvariations %}
{% for category_groups in article.productvariations.split('|') %}
{% for category in category_groups.split('=') %}
{% if loop.first %}
<h1>{{ category }}</h1>
{% else %}
<ul>
{% for list in category.split(',') %}
{% set itemvalues = list.split(':') %}
<li>{{ itemvalues[0] }} costs {{itemvalues [1]}}
{% endfor %}
</ul>
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
@hyperking
Copy link
Author

Thanks to talha131 for help on this solution
https://gist.github.com/talha131/6642646#file-hyperking-prob-sol-1

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