Pagination can be used directly within content. You can paginate any list, not just a list of pages.
It is important to ensure that pagination is not called twice within the same physical page (i.e., make sure the pagination function is not called in the template of this page, and that it is not called more than once either in the content or in the template).
This feature has been available since version 0.1.8b. In previous versions, pagination only worked in templates.
{# The second parameter is the number of list items per page #}
{# It can be omitted — then the value from the configuration file will be used #}
{{ splitToPages(datasets.examples.movies, 10) }}
{# You can do almost anything with the list #}
{{ page.list_page | to_table(["name_en", "director_en"]) }}
{# The template should include pagination output #}
| Title | Director |
|---|---|
| Zack Snyder's Justice League | Zack Snyder |
| Wonder Woman 1984 | Patty Jenkins |
| Birds of Prey and the Fantabulous Emancipation of One Harley Quinn | Cathy Yan |
| Joker | Todd Phillips |
| Spider-Man: Far from Home | John Watts |
| Avengers: Endgame | Anthony Russo, Joe Russo |
| Shazam! | David F. Sandberg |
| Captain Marvel | Anna Boden, Ryan Fleck |
| Aquaman | James Wan |
| Ant-Man and the Wasp | Peyton Reed |