| {% block extends %}
{{ "{% extends 'base.html.twig' %}" }}
{% endblock extends %}
{% block body %}
{{ "{% block body %}" }}
    <h1>{{ entity }} list</h1>
    <table>
        <thead>
            <tr>
            {%- for field, metadata in fields %}
                <th>{{ field|capitalize }}</th>
            {%- endfor %}
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
        {{ '{% for ' ~ entity_singularized ~ ' in ' ~ entity_pluralized ~ ' %}' }}
            <tr>
        {%- for field, metadata in fields %}
            {%- if loop.first and ('show' in actions) %}
                <td><a href="{{ "{{ path('" ~ route_name_prefix ~ "_show', { 'id': " ~ entity_singularized ~ "."~ identifier ~" }) }}" }}">{{ '{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' }}' }}</a></td>
            {%- elseif metadata.type in ['datetime'] %}
                <td>{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|date(\'Y-m-d H:i:s\') }}{% endif %}' }}</td>
            
            {%- elseif metadata.type in ['date'] %}
                <td>{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|date(\'Y-m-d\') }}{% endif %}' }}</td>
          
            {%- elseif metadata.type in ['time'] %}
                <td>{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|date(\'H:i:s\') }}{% endif %}' }}</td>
            {%- elseif metadata.type in ['array'] %}
                <td>{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|join(\', \') }}{% endif %}' }}</td>
            {%- elseif metadata.type in ['boolean'] %}
                <td>{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}Yes{% else %}No{% endif %}' }}</td>
            {%- else %}
                <td>{{ '{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' }}' }}</td>
            {%- endif %}
            {%- if loop.last %}
                <td>
                    <ul>
                    {%- for action in record_actions %}
                        <li>
                            <a href="{{ "{{ path('" ~ route_name_prefix ~ "_" ~ action ~ "', { 'id': " ~ entity_singularized ~ "."~ identifier ~" }) }}" }}">{{ action }}</a>
                        </li>
                    {%- endfor %}
                    </ul>
                </td>
            {%- endif %}
        {%- endfor %}
            </tr>
        {{ '{% endfor %}' }}
        </tbody>
    </table>
    {% if 'new' in actions -%}
    <ul>
        <li>
            <a href="{{ "{{ path('" ~ route_name_prefix ~ "_new') }}" }}">Create a new entry</a>
        </li>
    </ul>
    {%- endif %}
{{ "{% endblock %}" }}
{% endblock body %}
 |