{% macro render_value(value) -%}
    {{ value }}
{%- endmacro %}

{% macro render_list(list) -%}
    <ul>
    {% for elem in list %}
        <li>{{ render_element(elem) }}</li>
    {% endfor %}
    </ul>
{%- endmacro %}

{% macro render_dict(dict) -%}
    <ul>
    {% for key, value in dict.items() %}
        <li>{{ key }}: {{ render_element(value) }}</li>
    {% endfor %}
    </ul>
{%- endmacro %}

{% macro render_element(element) -%}
    {% if element is mapping %}
        {{ render_dict(element) }}
    {% elif element is iterable and element is not string %}
        {{ render_list(element) }}
    {% else %}
        {{ render_value(element) }}
    {% endif %}
{%- endmacro %}

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Bolinette</title>
</head>
<body>
    <h1>{{ response['code'] }} {{ response['status'] }}</h1>
    {% if response['messages']|length %}
    <hr />
    <h2>Messages</h2>
    {{ render_element(response['messages']) }}
    {% endif %}
    {% if response['data']|length %}
    <hr />
    <h2>Content</h2>
    {{ render_element(response['data']) }}
    {% endif %}
</body>
</html>
