{% set events = upcoming.events %}

{% if not events.error and events is not empty %}
    <table>
        <thead>
        <th>Calendar Name</th>
        <th>Event Name</th>
        <th>Location</th>
        <th>Description</th>
        <th>Start Time</th>
        <th>End Time</th>
        </thead>
        <tbody>
        {% for event in events %}
            <tr>
                <td style="padding: 0 10px 5px 20px; border-left: 6px solid {{ event.color }};">{{ event.calendar_name }}</td>
                <td style="padding: 0 10px 5px 20px;">{{ event.event_name }}</td>
                <td style="padding: 0 10px 5px 20px;">{{ event.location }}</td>
                <td style="padding: 0 10px 5px 20px;">{{ event.description|raw }}</td>
                <td style="padding: 0 10px 5px 20px;">{{ event.start_time|date("Y-m-d H:i") }}</td>
                <td style="padding: 0 10px 5px 20px;">{{ event.end_time|date("Y-m-d H:i") }}</td>
            </tr>
        {% else %}
            <tr>
                <td colspan="6">No events found.</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% elseif events.error %}
    {% for item in events %}
        <p style="color: red"><b>{{ item.code }}</b> - {{ item.message }}</p>
    {% endfor %}

{% else %}
    <p>Events cannot be displayed.</p>
{% endif %}
