{% if contentList|length %}
    <div class="bloc-grille">
        <div class="container">
            <ul class="grid">
                {% for id,contents in contentList %}
                    {% for index, content in contents %}
                        {# Default parameters #}
                        {% set link = "" %}
                        {% set target = 0 %}
                        {% set data_rel = 0 %}
                        {% set video_item = "" %}

                        {# Link #}
                        {% set link = get_link_by_content_id(content.id) %}
                        {% if ez_is_field_empty(content, 'lien_interne' ) and ez_is_field_empty(content, 'url' )
                        and content.fields.code_video is defined and not ez_is_field_empty(content, "code_video")  %}
                            {% set link = "#iframe_"~id~"_"~index %}
                            {% set video_item = "video-item" %}
                        {% endif %}

                        {# Target #}
                        {% if content.fields.nouvelle_fenetre is defined and not ez_is_field_empty(content, "nouvelle_fenetre")
                        and content.getFieldValue('nouvelle_fenetre').bool %}
                            {% set target = 1 %}
                        {% endif %}

                        {# Data Rel : prettyPhoto #}
                        {% if ez_is_field_empty(content, 'lien_interne' ) and ez_is_field_empty(content, 'url' )
                        and (content.fields.code_video is defined and not ez_is_field_empty(content,'code_video')) %}
                            {% set data_rel= 1 %}
                        {% endif %}

                        <li class="grid-item item{{ contents|length }}">
                            <div class="grid-item-in {{ video_item }}">
                                <a href="{{ link }}" {% if target %} target="_blank"{% endif %} {% if data_rel %} data-rel="prettyPhoto"{% endif %}>
                                    {% if content.getFieldValue('image').uri %}
                                        {{ ez_render_field(content, 'image', {'parameters': { 'alias': 'bloc_home' }}) }}
                                    {% endif %}
                                    {% if content.fields.afficher_titre_bloc is defined and not ez_is_field_empty(content,'afficher_titre_bloc') and content.getFieldValue('afficher_titre_bloc').bool %}
                                        <div class="front">
                                            <div class="description">
                                                <h3>
                                                    {{ ez_field_value(content, "titre")|raw }}
                                                </h3>
                                            </div>
                                        </div>
                                    {% endif %}

                                    {% if ez_is_field_empty(content, 'lien_interne' ) and ez_is_field_empty(content, 'url' )
                                    and (content.fields.code_video is defined and not ez_is_field_empty(content,'code_video')) %}
                                        <span class="picto-video"></span>
                                        <div id="iframe_{{ id }}_{{ index }}" class="inline-content-galerie">
                                            {{ content.getFieldValue("code_video")|raw }}
                                        </div>
                                    {% endif %}

                                    <div class="back">
                                        <div class="description">
                                            <h3>
                                                {{ ez_field_value(content, "titre")|raw }}
                                            </h3>
                                            <p>
                                                {{ content.getFieldvalue('texte')|truncate(220, true, '...')|raw }}
                                            </p>
                                        </div>
                                    </div>
                                </a>
                            </div>
                        </li>
                    {% endfor %}
                {% endfor %}
            </ul>
        </div>
    </div>
{% endif %}