{% macro alert(type,alerts,error_class) %}
    {% if(alerts|length) %}
        <div class="{{ type }} {{ error_class }}">
            {% if alerts is iterable %}
                <ul>
                    {% for alert in alerts %}
                        <li>{{ alert|raw }}</li>
                    {% endfor %}
                </ul>
            {% else %}
                {{ alerts|raw }}
            {% endif  %}
        </div>
    {% endif %}
{% endmacro %}

{% macro list_tree(tree, clones = false) %}
    {% for tree_item in tree %}
        <li class="{% if tree_item.sub_tree is not empty %}parent{% endif %}{% if tree_item.url == current_uri() ~ '/' %} active{% endif %}">

            <a href="{{ tree_item.url }}">
                {{ tree_item.name }}
            </a>

            {% if tree_item.sub_tree %}
                <ul>
                    {% if clones %}
                        <li>
                            <a href="{{ tree_item.url }}">
                                View all {{ tree_item.name }}
                            </a>
                        </li>
                    {% endif %}
                    {{ _self.list_tree(tree_item.sub_tree, clones) }}
                </ul>
            {% endif %}

        </li>
    {% endfor %}
{% endmacro %}
