Last active
June 21, 2024 17:50
Revisions
-
isthatcentered revised this gist
Oct 16, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -22,8 +22,8 @@ {# Nav Being the variable passed to the template #} {% if nav %} {# importing the macro created earlier #} {% import _self as tree %} {# using macro {nameOfImport}.{nameOfMethod}(variable) #} {{ tree.list(nav.children) }} {% endif %} -
isthatcentered created this gist
Oct 16, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ {% macro list(items, class) %} <ul class="{{class}}"> {# Iterating over each direct items #} {% for item in items %} <li> <a href="">{{item.name}}</a> {# If an item has children #} {% if item.children %} {# Re-import the macro #} {% import _self as recursive %} {# And use it to iterate over item's children #} {{ recursive.list(item.children) }} {% endif %} </li> {% endfor %} </ul> {% endmacro %} {# Nav Being the variable passed to the template #} {% if nav %} {# importing the macro created earlier #} {% import _self as recursive %} {# using macro {nameOfImport}.{nameOfMethod}(variable) #} {{ recursive.list(nav.children) }} {% endif %}