Module: Pagy::SupportExtra

Included in:
Frontend
Defined in:
lib/pagy/extras/support.rb

Overview

Extra support for features like: incremental, auto-incremental and infinite pagination

Instance Method Summary collapse

Instance Method Details

Return the HTML string for the next page link



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pagy/extras/support.rb', line 31

def pagy_next_link(pagy, text: pagy_t('pagy.nav.next'), link_extra: '')
  if pagy.next
    %(<span class="page next"><a href="#{
        pagy_url_for(pagy, pagy.next)
      }" rel="next" aria-label="next" #{
        pagy.vars[:link_extra]
      } #{link_extra}>#{text}</a></span>)
  else
    %(<span class="page next disabled">#{text}</span>)
  end
end

Return the HTML link tag for the next page or nil



49
50
51
# File 'lib/pagy/extras/support.rb', line 49

def pagy_next_link_tag(pagy)
  %(<link href="#{pagy_url_for(pagy, pagy.next)}" rel="next"/>) if pagy.next
end

#pagy_next_url(pagy) ⇒ Object

Return the next page URL string or nil



13
14
15
# File 'lib/pagy/extras/support.rb', line 13

def pagy_next_url(pagy)
  pagy_url_for(pagy, pagy.next) if pagy.next
end

Return the HTML string for the previous page link



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pagy/extras/support.rb', line 18

def pagy_prev_link(pagy, text: pagy_t('pagy.nav.prev'), link_extra: '')
  if pagy.prev
    %(<span class="page prev"><a href="#{
        pagy_url_for(pagy, pagy.prev)
      }" rel="prev" aria-label="previous" #{
        pagy.vars[:link_extra]
      } #{link_extra}>#{text}</a></span>)
  else
    %(<span class="page prev disabled">#{text}</span>)
  end
end

Return the HTML link tag for the previous page or nil



44
45
46
# File 'lib/pagy/extras/support.rb', line 44

def pagy_prev_link_tag(pagy)
  %(<link href="#{pagy_url_for(pagy, pagy.prev)}" rel="prev"/>) if pagy.prev
end

#pagy_prev_url(pagy) ⇒ Object

Return the previous page URL string or nil



8
9
10
# File 'lib/pagy/extras/support.rb', line 8

def pagy_prev_url(pagy)
  pagy_url_for(pagy, pagy.prev) if pagy.prev
end