Sha256: 0b656b45cb43eb1e0276ab66efc4d6470a55e3d53bd79fcf1e1a11b9858b0a54
Contents?: true
Size: 971 Bytes
Versions: 1
Compression:
Stored size: 971 Bytes
Contents
# frozen_string_literal: true class Pagy # Provide the helpers to handle the url in frontend and backend module UrlHelpers # This works with all Rack-based frameworks (Sinatra, Padrino, Rails, ...) def pagy_url_for(pagy, page, absolute: nil) p_vars = pagy.vars params = request.GET.merge(p_vars[:params]) params[p_vars[:page_param].to_s] = page params[p_vars[:items_param].to_s] = p_vars[:items] if defined?(ItemsExtra) # we rely on Rack by default: use the standalone extra in non rack environments query_string = "?#{Rack::Utils.build_nested_query(pagy_massage_params(params))}" unless params.empty? "#{request.base_url if absolute}#{request.path}#{query_string}#{p_vars[:fragment]}" end # Sub-method called only by #pagy_url_for: here for easy customization of params by overriding def pagy_massage_params(params) params end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pagy-5.0.0 | lib/pagy/url_helpers.rb |