Created
July 22, 2015 01:11
-
-
Save nanasess/92213029d36219f1ab3e to your computer and use it in GitHub Desktop.
twig で再帰処理 ref: http://qiita.com/nanasess/items/5a1a6dbc1090e8ec0b36
This file contains 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
{% macro recursiveCategories(Category) %} | |
{% if Category.hasChildNodes() %} | |
<ul> | |
{% for child in Category.childNodes() %} | |
<li>{{ child.name }}</li> | |
{{ _self.recursiveCategories(child) }} | |
{% endfor %} | |
</ul> | |
{% endif %} | |
{% endmacro %} | |
{% if Category.hasChildNodes() %} | |
<ul> | |
{% for ChildCategory in Category.childNodes() %} | |
<li>{{ ChildCategory.name }}</li> | |
{{ _self.recursiveCategories(ChildCategory) }} | |
{% endfor %} | |
</ul> | |
{% endif %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment