Sha256: cbe4edb454f192663f12eef8e0d3b9fc406b64bc219684e8a2ee43fde218aeaf

Contents?: true

Size: 1.49 KB

Versions: 12

Compression:

Stored size: 1.49 KB

Contents

# See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/support
# frozen_string_literal: true

class Pagy # :nodoc:
  # Extra support for features like: incremental, auto-incremental and infinite pagination
  module SupportExtra
    # Return the previous page URL string or nil
    def pagy_prev_url(pagy, absolute: false)
      pagy_url_for(pagy, pagy.prev, absolute:) if pagy.prev
    end

    # Return the next page URL string or nil
    def pagy_next_url(pagy, absolute: false)
      pagy_url_for(pagy, pagy.next, absolute:) if pagy.next
    end

    # Return the HTML string for the enabled/disabled previous page link
    def pagy_prev_html(pagy, text: pagy_t('pagy.prev'), link_extra: '')
      link = pagy_link_proc(pagy, link_extra:)
      prev_html(pagy, link, text:)
    end

    # Return the HTML string for the enabled/disabled next page link
    def pagy_next_html(pagy, text: pagy_t('pagy.next'), link_extra: '')
      link = pagy_link_proc(pagy, link_extra:)
      next_html(pagy, link, text:)
    end

    # Conditionally return the HTML link tag string for the previous page
    def pagy_prev_link_tag(pagy, absolute: false)
      %(<link href="#{pagy_url_for(pagy, pagy.prev, absolute:)}" rel="prev"/>) if pagy.prev
    end

    # Conditionally return the HTML link tag string for the next page
    def pagy_next_link_tag(pagy, absolute: false)
      %(<link href="#{pagy_url_for(pagy, pagy.next, absolute:)}" rel="next"/>) if pagy.next
    end
  end
  Frontend.prepend SupportExtra
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pagy-7.0.11 lib/pagy/extras/support.rb
pagy-7.0.10 lib/pagy/extras/support.rb
pagy-7.0.9 lib/pagy/extras/support.rb
pagy-7.0.8 lib/pagy/extras/support.rb
pagy-7.0.7 lib/pagy/extras/support.rb
pagy-7.0.6 lib/pagy/extras/support.rb
pagy-7.0.5 lib/pagy/extras/support.rb
pagy-7.0.4 lib/pagy/extras/support.rb
pagy-7.0.3 lib/pagy/extras/support.rb
pagy-7.0.2 lib/pagy/extras/support.rb
pagy-7.0.1 lib/pagy/extras/support.rb
pagy-7.0.0 lib/pagy/extras/support.rb