{% macro scalar(key, value) -%}
    {% if value is mapping %}
        <li><details>
            <summary class="pystac-summary"><span class="pystac-k">{{ key }}</span></summary>
            {{ dict(value) }}
        </details></li>
    {% else %}
        <li class="pystac-row">
            <span class="pystac-k">{{ key }}</span>
            <span class="pystac-v">{% if value is string %}"{{ value }}"{% else %}{{ value }}{% endif %}</span>
        </li>
    {% endif %}
{%- endmacro %}

{% macro list(key, value) -%}
    <li><details>
        <summary class="pystac-summary"><span class="pystac-k">{{ key }}</span><span class="pystac-l">[] {{ value|length }} items</span></summary>
        {% for item in value %}
            {{ dict({loop.index - 1: item}) }}
        {% endfor %}
    </details></li>
{%- endmacro %}

{% macro dict(dict) -%}
    <ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
        {% for key, value in dict.items() %}
            {% if value is iterable and (value is not string and value is not mapping) %}
                {{ list(key, value) }}
            {% else %}
                {{ scalar(key, value) }}
            {% endif %}
        {% endfor %}
    </ul>
{%- endmacro %}