Skip to content

Instantly share code, notes, and snippets.

@MaximStrutinskiy
Last active December 3, 2018 19:40
Show Gist options
  • Save MaximStrutinskiy/04db10aa092041cfe38479a2ca3d6606 to your computer and use it in GitHub Desktop.
Save MaximStrutinskiy/04db10aa092041cfe38479a2ca3d6606 to your computer and use it in GitHub Desktop.
Twig macro - [time ~ 2.8s]
{% import _self as recursive_category_macro %}
{% macro recursive_category(category, recursive_category_macro) %}
<li>
<h4>{{ category.nameRu }}</h4>
{% if category.SChildren|length %}
<ul>
{% for child in category.SChildren %}
{{ recursive_category_macro.recursive_category(child, recursive_category_macro) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}
{% if categories %}
<div id="categories">
<ul>
{% for category in categories %}
{{ recursive_category_macro.recursive_category(category, recursive_category_macro) }}
{% endfor %}
</ul>
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment