{% set attr_extra = '' %}
{% if segment.attributes.extra %}
    {% for attributes in segment.attributes.extra %}
        {% for key, value in attributes %}
            {% set attr_extra = attr_extra ~ ' ' ~ key|e ~ '="' ~ value|e('html_attr') ~ '"' %}
        {% endfor %}
    {% endfor %}
{% endif %}

{% set html %}
    {% if segment.children %}
        {% for segment in segments %}
            {% if segment.content %}
                {{ segment.content|raw }}
            {% else %}
                {% include ['@nucleus/content/' ~ segment.type ~ '.html.twig', '@nucleus/layout/' ~ segment.type ~ '.html.twig'] with { 'segments': segment.children } %}
            {% endif %}
        {% endfor %}
    {% endif %}
{% endset %}

{% if html|trim %}
    <div {% if segment.attributes.id %}id="{{ segment.attributes.id|e }}"{% endif %}
        {{ attr_extra|raw }}
         class="g-block{{ segment.attributes.variations ? ' ' ~ segment.attributes.variations|join(' ')|e }}{{ segment.attributes.class ? ' ' ~ segment.attributes.class|join(' ')|e }} {{ segment.attributes.size|toGrid }}">
        {{ html|raw }}
    </div>
{% endif %}
