Pooru/templates/_pager.html.ep
Lucas Gabriel Vuotto 1a0a224edc site: extend extended_pager
Make it return a hash for page numbers and shortcuts. Move logic
handling for the shortcuts from the templates to the helper. Make the
pager length configurable. Add a helper for producing the shortcuts'
links.
2025-04-26 13:29:29 +00:00

18 lines
655 B
Text

% if (my $pager = stash("pager")) {
% my ($pages, $shortcuts) = {extended_pager($pager)}->@{qw(pages shortcuts)};
<footer>
<nav class="text-center pager">
<%= tag_for_pager_shortcut "<<", $shortcuts->{first_page} %>
<%= tag_for_pager_shortcut "<", $shortcuts->{previous_page} %>
% for my $page ($pages->@*) {
% if ($page == $pager->{current_page}) {
<span><%= $pager->{current_page} %></span>
% } else {
<%= link_to $page => url_with->query({page => $page}) %>
% }
% }
<%= tag_for_pager_shortcut ">", $shortcuts->{next_page} %>
<%= tag_for_pager_shortcut ">>", $shortcuts->{last_page} %>
</nav>
</footer>
% }