Skip to content

Instantly share code, notes, and snippets.

@mariohernandez
Created June 3, 2019 14:51
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 mariohernandez/42cad06d65ab2c3d4d5544e719022dcc to your computer and use it in GitHub Desktop.
Save mariohernandez/42cad06d65ab2c3d4d5544e719022dcc to your computer and use it in GitHub Desktop.
{% import _self as menus %}
{{ menus.main_menu(items, attributes, 0) }}
{% macro main_menu(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
<ul{{ attributes }}>
{% else %}
<ul>
{% endif %}
{% for item in items %}
<li{{ item.attributes }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.main_menu(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment