{% extends 'logs/entry_base.html' %}

{% macro render_diff(data) %}
    {% for key, values in data.items() if key != '_diff' %}
        {{ render_row(key, compare(*values), content_class='diff preformatted') }}
    {% endfor %}
{% endmacro %}

{% macro render_row(caption, content, content_class='', html=false) %}
    <tr class="i-table content">
        <td class="i-table caption log-caption">
            {{ caption }}
        </td>
        <td class="i-table value searchable">
            <div class="{{ content_class }}">
                {%- if content is not string and content is sequence %}
                    <ul>
                        {% for item in content %}
                            <li>{{ item }}</li>
                        {% endfor %}
                    </ul>
                {% elif html %}
                    {{- content|sanitize_html -}}
                {% else %}
                    {{- content -}}
                {% endif -%}
            </div>
        </td>
    </tr>
{% endmacro %}

{% block entry_detail_rows %}
    {% for key, value in data.items() if value not in ('', none) and key != '_html_fields' %}
        {% if value._diff %}
            {{ render_diff(value) }}
        {% else %}
            {{ render_row(key, value, html=(key in data._html_fields|default([]))) }}
        {% endif %}
    {% else %}
        <tr class="i-table content">
            <td class="i-table caption log-caption"></td>
            <td class="i-table value empty">
                {% trans %}No data to display{% endtrans %}
            </td>
        </tr>
    {% endfor %}
{% endblock %}
