lib/pagy/extras/trim.rb in pagy-1.3.3 vs lib/pagy/extras/trim.rb in pagy-2.0.0
- old
+ new
@@ -1,6 +1,7 @@
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/trim
+# encoding: utf-8
# frozen_string_literal: true
class Pagy
module Frontend
@@ -13,10 +14,10 @@
p_prev, p_next, p_vars = pagy.prev, pagy.next, pagy.vars
marker_url = pagy_url_for(MARKER, pagy)
page1_url = pagy_trim_url(marker_url, "#{p_vars[:page_param]}=#{MARKER}")
page1_link = %(<a href="#{page1_url}" #{p_vars[:link_extra]} #{link_extra})
a, b = %(<a href="#{marker_url}" #{p_vars[:link_extra]} #{link_extra}).split(MARKER, 2)
- -> (n, text=n, extra='') { start = n.to_i == 1 ? page1_link : "#{a}#{n}#{b}"
+ lambda{|n, text=n, extra=''| start = n.to_i == 1 ? page1_link : "#{a}#{n}#{b}"
"#{start}#{ if n == p_prev ; ' rel="prev"'
elsif n == p_next ; ' rel="next"'
else '' end } #{extra}>#{text}</a>" }
end
alias_method :pagy_link_proc, :pagy_link_proc_with_trim