Module: Pagy::StandaloneExtra
Overview
Use pagy without any request object, nor Rack environment/gem, nor any defined params method, even in the irb/rails console without any app or config.
Defined Under Namespace
Modules: QueryUtils
Instance Method Summary collapse
-
#pagy_url_for(pagy, page, absolute: false, html_escaped: false) ⇒ Object
Return the URL for the page.
Instance Method Details
#pagy_url_for(pagy, page, absolute: false, html_escaped: false) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pagy/extras/standalone.rb', line 39 def pagy_url_for(pagy, page, absolute: false, html_escaped: false) return super unless pagy.vars[:url] vars = pagy.vars page_param = vars[:page_param].to_s items_param = vars[:items_param].to_s params = pagy.params.is_a?(Hash) ? pagy.params.clone : {} # safe when it gets reused params[page_param] = page params[items_param] = vars[:items] if vars[:items_extra] query_string = "?#{QueryUtils.build_nested_query(pagy_deprecated_params(pagy, params))}" # remove in 6.0 # params = pagy.params.call(params) if pagy.params.is_a?(Proc) # add in 6.0 # query_string = "?#{Rack::Utils.build_nested_query(params)}" # add in 6.0 query_string = query_string.gsub('&', '&') if html_escaped # the only unescaped entity "#{vars[:url]}#{query_string}#{vars[:fragment]}" end |