Sha256: 9b7b41f3cd5559b70ccc8aa077b8ffe229b21812caeeb144e42ed4b722b052da

Contents?: true

Size: 1.76 KB

Versions: 16

Compression:

Stored size: 1.76 KB

Contents

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

class Pagy

  module Frontend

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

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

    def pagy_prev_link(pagy, deprecated_text=nil, deprecated_link_extra=nil, text: pagy_t('pagy.nav.prev'), link_extra: '')
      text       = Pagy.deprecated_arg(:text, deprecated_text, :text, text) if deprecated_text
      link_extra = Pagy.deprecated_arg(:link_extra, deprecated_link_extra, :link_extra, link_extra) if deprecated_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

    def pagy_next_link(pagy, deprecated_text=nil, deprecated_link_extra=nil, text: pagy_t('pagy.nav.next'), link_extra: '')
      text       = Pagy.deprecated_arg(:text, deprecated_text, :text, text) if deprecated_text
      link_extra = Pagy.deprecated_arg(:link_extra, deprecated_link_extra, :link_extra, link_extra) if deprecated_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

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

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

  end

end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/pagy/extras/support.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/pagy/extras/support.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/pagy/extras/support.rb
pagy-4.11.0 lib/pagy/extras/support.rb
pagy-4.10.2 lib/pagy/extras/support.rb
pagy-4.10.1 lib/pagy/extras/support.rb
pagy-4.10.0 lib/pagy/extras/support.rb
pagy-4.9.0 lib/pagy/extras/support.rb
pagy-4.8.1 lib/pagy/extras/support.rb
pagy-4.8.0 lib/pagy/extras/support.rb
pagy-4.7.1 lib/pagy/extras/support.rb
pagy-4.7.0 lib/pagy/extras/support.rb
pagy-4.6.0 lib/pagy/extras/support.rb
pagy-4.5.1 lib/pagy/extras/support.rb
pagy-4.5.0 lib/pagy/extras/support.rb
pagy-4.4.0 lib/pagy/extras/support.rb