{% if item.hasChildren() and (options.depth is not same as 0) and item.getDisplayChildren()  %}

    {# get attributes from item + the ones passed from parent #}
    {% set ulAttributes = item.getChildrenAttributes() %}
    {# save default classes for the item #}
    {% set ulClasses = (ulAttributes.class is defined) ? ulAttributes.class ~ ' dropdown-menu' : 'dropdown-menu' %}
    {# replace classes with enhanced class object #}
    {% set ulAttributes = ulAttributes|merge({'class': ulClasses}) %}

    <ul{{ parseMenuAttributes(ulAttributes) }}>

        {% for child in item.getChildren() %}

            {% if child.isDisplayed() %}

                {% set showChildren = (child.hasChildren() and child.getDisplayChildren() ? true : false) %}
                {% set liAttributes = child.getAttributes() %}
                {% set isAncestor = matcher.isAncestor(child, options['matchingDepth']) %}
                {% set extras = child.getExtras() %}

                {% if (extras.divider is defined and extras.divider is not empty) %}
                    <li role="separator" class="divider"></li>
                {% elseif (extras.header is defined and extras.header is not empty) %}
                    <li class="dropdown-header">{{ extras.header|trans|purify }}</li>
                {% else %}
                    {# save default classes for the item #}
                    {% set liClasses = (liAttributes.class is defined) ? liAttributes.class : '' %}
                
                    {# fetch classes from options and merge with the default classes #}
                    {% set liAttributes = liAttributes|merge(buildMenuClasses(child, matcher, options, liClasses)) %}

                    <li{{ parseMenuAttributes(liAttributes) }}>

                        {% set url = child.getUri() %}
                        {% set linkAttributes = child.getLinkAttributes() %}
                        {% set url = (url is empty) ? 'javascript:void(0);' : url %}
                        {% if (linkAttributes.target is not defined or linkAttributes.target is empty) %}
                            {% set linkAttributes = linkAttributes|merge({'data-toggle': 'ajax'}) %}
                        {% endif %}
                        <a href="{{url}}"{{ parseMenuAttributes(linkAttributes) }}>
                            {% if (extras.iconClass is defined and extras.iconClass is not empty) %}
                            <span style="margin-top: 4px;" class="icon pull-left fa {{ extras.iconClass }}"></span>
                            {% endif %}

                            {% set labelAttributes = child.getLabelAttributes() %}
                        
                            {% set labelClasses = (labelAttributes.class is not defined) ? 'text' : labelAttributes.class ~ ' text' %}
                            {% set labelAttributes = labelAttributes|merge({'class': labelClasses|trim }) %}

                            <span{{ parseMenuAttributes(labelAttributes) }}>{{ child.getLabel() | trans | purify }}</span>
                        </a>
                    </li>

                {% endif %}

            {% endif %}

        {% endfor %}

    </ul>

{% endif %}
