You are here

cheeseburger-menu.html.twig in Cheeseburger Menu 8.4

Same filename and directory in other branches
  1. 5.0.x templates/cheeseburger-menu.html.twig
{% import _self as cheesebuger %}
{% if show_navigation %}
    <div class="cheeseburger-menu__navigation">
        <ul class="cheeseburger-menu__navigation-list">
            {% for item in tree %}
                <li class="cheeseburger-menu__navigation-list-item cheeseburger-menu__navigation-list-item--{{ item.id }}"
                    data-drupal-selector="cheeseburger-menu--{{ item.id }}">
                    {% if item.url %}
                        <a href="{{ item.url }}">{{ item.navigation_title }}</a>
                    {% else %}
                        <span>{{ item.navigation_title }}</span>
                    {% endif %}
                </li>
            {% endfor %}
        </ul>
    </div>
{% endif %}
<div class="cheeseburger-menu__menus">
    {% for menu in tree %}
        {% if menu['#cheeseburger_ignore'] %}
            {{ menu }}
        {% else %}
            <div class="cheeseburger-menu__menu cheeseburger-menu__menu--{{ menu.id }}"
                 data-drupal-selector="cheeseburger-menu--{{ menu.id }}">
                <span class="cheeseburger-menu__menu-list-trigger"></span>
                {% if menu.title != "" %}
                    <div class="cheeseburger-menu__menu-title{{ menu.collapsible_title }}">{{ menu.title }}</div>
                {% endif %}
                {% if menu.tree %}
                    <ul class="cheeseburger-menu__menu-list">
                        {{ cheesebuger.renderTree(menu.tree, parent_menu_as_link) }}
                    </ul>
                {% endif %}
            </div>
        {% endif %}
    {% endfor %}
</div>

{% macro renderTree(tree, parent_menu_as_link) %}
    {% import _self as render_tree %}
    {% if tree|length > 0 %}
        <ul class="cheeseburger-menu__menu-list">
            {% for item in tree %}
                {% if item.children|length > 0 %}
                    <li class="cheeseburger-menu__menu-list-item cheeseburger-menu__menu-list-item--parent cheeseburger-menu__menu-list-item--expanded">
                {% else %}
                    <li class="cheeseburger-menu__menu-list-item cheeseburger-menu__menu-list-item--child">
                {% endif %}
                {% if item.icon %}
                    <img src="{{ item.icon }}" class="cheeseburger-menu__menu-list-item-image">
                {% endif %}
                {% if item.children|length > 0 %}
                    {% if parent_menu_as_link %}
                      <span class="cheeseburger-menu__menu-list-item-link cheeseburger-menu__menu-list-item-link--span {{ item.active }}">
                        <a href="{{ item.url }}" class="cheeseburger-menu__menu-list-item-link {{ item.active }}">{{ item.title }}</a>
                      </span>
                    {% else %}
                      <span class="cheeseburger-menu__menu-list-item-link cheeseburger-menu__menu-list-item-link--span {{ item.active }}">{{ item.title }}</span>
                    {% endif %}
                {% else %}
                    <a href="{{ item.url }}" class="cheeseburger-menu__menu-list-item-link {{ item.active }}">{{ item.title }}</a>
                {% endif %}
                  {{ render_tree.renderTree(item.children, parent_menu_as_link) }}
                </li>
            {% endfor %}
        </ul>
    {% endif %}
{% endmacro %}

File

templates/cheeseburger-menu.html.twig
View source
  1. {% import _self as cheesebuger %}
  2. {% if show_navigation %}
  3. <div class="cheeseburger-menu__navigation">
  4. <ul class="cheeseburger-menu__navigation-list">
  5. {% for item in tree %}
  6. <li class="cheeseburger-menu__navigation-list-item cheeseburger-menu__navigation-list-item--{{ item.id }}"
  7. data-drupal-selector="cheeseburger-menu--{{ item.id }}">
  8. {% if item.url %}
  9. <a href="{{ item.url }}">{{ item.navigation_title }}</a>
  10. {% else %}
  11. <span>{{ item.navigation_title }}</span>
  12. {% endif %}
  13. </li>
  14. {% endfor %}
  15. </ul>
  16. </div>
  17. {% endif %}
  18. <div class="cheeseburger-menu__menus">
  19. {% for menu in tree %}
  20. {% if menu['#cheeseburger_ignore'] %}
  21. {{ menu }}
  22. {% else %}
  23. <div class="cheeseburger-menu__menu cheeseburger-menu__menu--{{ menu.id }}"
  24. data-drupal-selector="cheeseburger-menu--{{ menu.id }}">
  25. <span class="cheeseburger-menu__menu-list-trigger"></span>
  26. {% if menu.title != "" %}
  27. <div class="cheeseburger-menu__menu-title{{ menu.collapsible_title }}">{{ menu.title }}</div>
  28. {% endif %}
  29. {% if menu.tree %}
  30. <ul class="cheeseburger-menu__menu-list">
  31. {{ cheesebuger.renderTree(menu.tree, parent_menu_as_link) }}
  32. </ul>
  33. {% endif %}
  34. </div>
  35. {% endif %}
  36. {% endfor %}
  37. </div>
  38. {% macro renderTree(tree, parent_menu_as_link) %}
  39. {% import _self as render_tree %}
  40. {% if tree|length > 0 %}
  41. <ul class="cheeseburger-menu__menu-list">
  42. {% for item in tree %}
  43. {% if item.children|length > 0 %}
  44. <li class="cheeseburger-menu__menu-list-item cheeseburger-menu__menu-list-item--parent cheeseburger-menu__menu-list-item--expanded">
  45. {% else %}
  46. <li class="cheeseburger-menu__menu-list-item cheeseburger-menu__menu-list-item--child">
  47. {% endif %}
  48. {% if item.icon %}
  49. <img src="{{ item.icon }}" class="cheeseburger-menu__menu-list-item-image">
  50. {% endif %}
  51. {% if item.children|length > 0 %}
  52. {% if parent_menu_as_link %}
  53. <span class="cheeseburger-menu__menu-list-item-link cheeseburger-menu__menu-list-item-link--span {{ item.active }}">
  54. <a href="{{ item.url }}" class="cheeseburger-menu__menu-list-item-link {{ item.active }}">{{ item.title }}</a>
  55. </span>
  56. {% else %}
  57. <span class="cheeseburger-menu__menu-list-item-link cheeseburger-menu__menu-list-item-link--span {{ item.active }}">{{ item.title }}</span>
  58. {% endif %}
  59. {% else %}
  60. <a href="{{ item.url }}" class="cheeseburger-menu__menu-list-item-link {{ item.active }}">{{ item.title }}</a>
  61. {% endif %}
  62. {{ render_tree.renderTree(item.children, parent_menu_as_link) }}
  63. </li>
  64. {% endfor %}
  65. </ul>
  66. {% endif %}
  67. {% endmacro %}