{% set attr_extra = segment.attributes.extra|attribute_array %}
{% set class = 'g-grid' ~ (segment.attributes.class ? ' ' ~ segment.attributes.class|join(' ')) %}

{%- set html %}
    {% if segment.children %}
        {% for segment in segments %}
            {% include '@nucleus/layout/' ~ segment.type ~ '.html.twig' with { 'segments':segment.children } %}
        {% endfor %}
    {% endif %}
{% endset %}

{%- if html|trim %}
        <div {% if segment.attributes.id %}id="{{ segment.attributes.id|e }}" {% endif %}class="{{ class }}" {{- attr_extra|raw }}>
          {{- html|raw -}}
        </div>
{% endif %}
