-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu_blocks.html.twig
56 lines (42 loc) · 1.6 KB
/
menu_blocks.html.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{% block item %}
{% import '@Menu/macro/helper.html.twig' as helper %}
{% if entry.type is same as constant('Braunstetter\\MenuBundle\\Items\\Item::TYPE_URL') %}
{% set path = entry.url %}
{% else %}
{% if entry.routeName %}
{% set path = entry.routeParameters ? path(entry.routeName, entry.routeParameters) : path(entry.routeName) %}
{% else %}
{% set path = null %}
{% endif %}
{% endif %}
{% set label = entry.label %}
{% set icon = entry.icon %}
{% set handle = label|lower %}
{% set selectedSubnavItem = selectedSubnavItem|default(null) %}
{% set current = selectedSubnavItem is same as handle or entry.current %}
{% set attr = entry.attr %}
{% set linkAttr = entry.linkAttr %}
{% if current or entry.inActiveTrail %}
{% set linkAttr = linkAttr|merge({'class' : (linkAttr.class|default('') ~ ' active')|trim }) %}
{% endif %}
{% if current %}
{% set linkAttr = linkAttr|merge({'class' : (linkAttr.class|default('') ~ ' current')|trim }) %}
{% endif %}
<div {{ helper.renderAttr(attr) }}>
{% set tag = path ? 'a' : 'span' %}
<{{ tag}} {% if path %}href="{{ path }}"{% endif %} {{ helper.renderAttr(linkAttr) }}>
{{ block('icon') }}
{{ label }}
</{{ tag }}>
{% for entry in entry.children %}
{{ block('item') }}
{% endfor %}
</div>
{% endblock %}
{% block icon %}
{% if icon %}
{{ source(icon) }}
{% else %}
{{ source('@Menu/svg/default_folder.svg') }}
{% endif %}
{% endblock %}