{% set class = class|default('') %}

{% if pageCount > 1 %}
    {% if style is defined and style == 'pager' %}

        {% set prev_label = prev_label|default('Previous') %}
        {% set next_label = next_label|default('Next') %}
        {% set aligned = aligned|default(false) %}

        <ul class="pager{% if class is not empty %} {{ class }}{% endif %}">
            {% if previous is defined %}
                <li{% if aligned %} class="previous"{% endif %}><a href="{{ path(route, query|merge({(pageParameterName): previous})) }}">{{ prev_label|raw }}</a></li>
            {% else %}
                <li class="disabled{% if aligned %} previous{% endif %}"><span>{{ prev_label|raw }}</span></li>
            {% endif %}
            {% if next is defined %}
                <li{% if aligned %} class="next"{% endif %}><a href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ next_label|raw }}</a></li>
            {% else %}
                <li class="disabled{% if aligned %} next{% endif %}"><span>{{ next_label|raw }}</span></li>
            {% endif %}
        </ul>
    {% else %}

        {% set prev_label = prev_label|default('&laquo;') %}
        {% set next_label = next_label|default('&raquo;') %}

        <ul class="pagination{% if class is not empty %} {{ class }}{% endif %}">
            {% if first_label is defined and first is defined and current != first %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): first})) }}">{{ first_label|raw }}</a></li>
            {% elseif last_label is defined %}
                <li class="disabled"><span>{{ first_label|raw }}</span></li>
            {% endif %}

            {% if previous is defined %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): previous})) }}">{{ prev_label|raw }}</a></li>
            {% else %}
                <li class="disabled"><span>{{ prev_label|raw }}</span></li>
            {% endif %}

            {% for page in pagesInRange %}
                {% if page != current %}
                    <li><a href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a></li>
                {% else %}
                    <li class="active"><span>{{ page }}</span></li>
                {% endif %}

            {% endfor %}

            {% if next is defined %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ next_label|raw }}</a></li>
            {% else %}
                <li class="disabled"><span>{{ next_label|raw }}</span></li>
            {% endif %}

            {% if last_label is defined and last is defined and current != last %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): last})) }}">{{ last_label|raw }}</a></li>
            {% elseif last_label is defined %}
                <li class="disabled"><span>{{ last_label|raw }}</span></li>
            {% endif %}
        </ul>
    {% endif %}
{% endif %}
