templates/Public/Public/menu.html.twig line 1

Open in your IDE?
  1. {% macro renderAttributes(attributes) %}
  2. {% for attributeKey, attributeValue in attributes -%}
  3. {{ attributeKey }}="{{ attributeValue }}"
  4. {%- endfor %}
  5. {% endmacro %}
  6. {% if menu is not empty %}
  7. {% import _self as macros %}
  8. <ul {{ macros.renderAttributes(menu.attributes) }}>
  9. {% for item in menu.items %}
  10. {% set hasRight = item.right is empty or is_granted(item.right) == item.hasRight %}
  11. {% if hasRight %}
  12. {% set attributes = item.attributes %}
  13. {% if attributes.class is defined %}
  14. {% set class = attributes.class|split(' ')|merge(['nav-item']) %}
  15. {% else %}
  16. {% set class = ['nav-item'] %}
  17. {% endif %}
  18. {% if item.slug is not empty %}
  19. {% set class = class|merge(['link-'~item.slug]) %}
  20. {% endif %}
  21. {% if loop.first %}
  22. {% set class = class|merge(['first']) %}
  23. {% endif %}
  24. {% if loop.last %}
  25. {% set class = class|merge(['last']) %}
  26. {% endif %}
  27. {% set uri = '' %}
  28. {% if item.url is not empty %}
  29. {% set uri = item.url %}
  30. {% elseif item.path is not empty %}
  31. {% set parameters = item.parameterValue + ['_locale', item.locale] %}
  32. {% set uri = path(item.path, item.parameterValue) %}
  33. {% endif %}
  34. {% if uri is not null %}
  35. {% set attributes = attributes|merge({class:class|join(' ')}) %}
  36. <li {{ macros.renderAttributes(attributes) }}>
  37. <a class="nav-link" href="{{ uri }}">{% if item.items is not empty %}<span>+</span>{% endif %}{{ item.title }}</a>
  38. {% if attributes['data-image'] is defined %}
  39. <img src="{{ asset(attributes['data-image']) }}" alt="{{ item.title }}" />
  40. {% endif %}
  41. </li>
  42. {% endif %}
  43. {% endif %}
  44. {% endfor %}
  45. </ul>
  46. {% endif %}
  47. {#{% block javascripts %}#}
  48. {# {{ parent() }}#}
  49. {# <script type="application/javascript" src="{{ asset('assets/app/menu.js') }}"></script>#}
  50. {#{% endblock %}#}