{% for key, source in sources %} {% set hasNested = (source.nested is defined and source.nested|length) -%} {% set pathMatch = (sourcePath[depth] is defined and sourcePath[depth] == key) -%} {% set selected = (pathMatch and sourcePath|length == depth + 1) -%} {{ source.label }} {% if hasNested %}
    {% include "_elements/modal/sources" with { sources: source.nested, depth: depth + 1 } %} {% endif %} {% endfor %}