imotilux-8.x-1.x-dev/templates/imotilux-tree.html.twig
templates/imotilux-tree.html.twig
{#
/**
* @file
* Default theme implementation to display a imotilux tree.
*
* Returns HTML for a wrapper for a imotilux sub-tree.
*
* Available variables:
* - items: A nested list of imotilux items. Each imotilux item contains:
* - attributes: HTML attributes for the imotilux item.
* - below: The imotilux item child items.
* - title: The imotilux link title.
* - url: The imotilux link URL, instance of \Drupal\Core\Url.
* - is_expanded: TRUE if the link has visible children within the current
* imotilux tree.
* - is_collapsed: TRUE if the link has children within the current imotilux tree
* that are not currently visible.
* - in_active_trail: TRUE if the link is in the active trail.
*
* @ingroup themeable
*/
#}
{% import _self as imotilux_tree %}
{#
We call a macro which calls itself to render the full tree.
@see https://twig.symfony.com/doc/1.x/tags/macro.html
#}
{{ imotilux_tree.imotilux_links(items, attributes, 0) }}
{% macro imotilux_links(items, attributes, menu_level) %}
{% import _self as imotilux_tree %}
{% 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 %}
{{ imotilux_tree.imotilux_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
