permanent
clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

item.html.twig
text/plain

Download raw (2.5 KB)

{% macro loop(elements) %}
    <ul>
        {% for key, item in elements %}
            {% if item is iterable %}
                {% if item[0] and item[0] is not iterable %}
                <li><strong style="vertical-align: top;">{{ key|replace('_', ' ')|capitalize|e }}:</strong>
                <span style="display: inline-block;">{{ item|join("<br>\n")|raw }}</span></li>
                {% else %}
                <li><strong>{{ key|replace('_', ' ')|capitalize|e }}</strong>:</li>
                {{ _self.loop(item) }}
                {% endif %}
            {% else %}
                <li><strong style="vertical-align: top;">{{ key|replace('_', ' ')|capitalize|e }}:</strong> <span style="display: inline-block;">{{ item|striptags('<br>')|replace({"\n": '<br>'})|raw }}</span></li>
            {% endif %}
        {% endfor %}
    </ul>
{% endmacro %}

{% set data = grav.twig.itemData %}

<h1>
    {{ config.plugins['data-manager'].types[type].item.title ?: type|replace({'_': ' '})|capitalize|e ~ " " ~ "PLUGIN_DATA_MANAGER.ITEM_DETAILS"|e|tu|raw }}
</h1>
<ul>
    {% if data['_data_type'] == 'form' %}
        <div>Form submitted: {{ data.timestamp|date('m/d/Y \\a\\t g:m:i A') }}</div><br>
        {% set data = data.content %}
    {% endif %}

    {% if data is not iterable %}
        {{ data|raw }}
    {% elseif config.plugins['data-manager'].types[type].item.fields %}
        {% for key, type in config.plugins['data-manager'].types[type].item.fields %}
            {% set item = data[key] %}
            <li class="page-item">
                <div class="row">
                    <strong>{{ type.name|capitalize|e }}</strong>:

                    {% if item is iterable %}
                        {{ _self.loop(item) }}
                    {% else %}
                        {{ item|striptags('<br>')|raw }}
                    {% endif %}
                </div>
            </li>
        {% endfor %}
    {% else %}
        {% for key, item in data %}
            <li class="page-item">
                <div class="row">
                    <strong style="vertical-align: top;">{{ key|replace('_', ' ')|capitalize|e }}:</strong>

                    {% if item is iterable %}
                        {{ _self.loop(item) }}
                    {% else %}
                        <span style="display: inline-block;">{{ item|striptags('<br>')|replace({"\n": '<br>'})|raw }}</span>
                    {% endif %}
                </div>
            </li>
        {% endfor %}
    {% endif %}
</ul>