Edit on GitHub
Jump to docs navigation

Twig Components / Methods / paginate

paginate()is a Twig function to rearrange (and remove) the empty places after using the filter(arrow) method:

{% set filteredRecords = [] %}

{% for record in records %}
    {% set filteredFields = record|filter(r => r.title == title) %}

    {% if filteredRecords|length > 0 %}
       {% set filteredRecords = filteredFields|merge([record}) %}
    {% endif %}
{% endfor %}

{% set records = filteredRecords %}

And then you can use:

{% set records = paginate(records) %}

Source: Bolt



Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.