Sha256: 6aa43dbf33614d2c2b22c474d1d788906d672f9abc1126489bf2446c8d2a0f58
Contents?: true
Size: 1.15 KB
Versions: 15
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true class Pagy # Provide the helpers to handle the url in frontend and backend module UrlHelpers # Return the URL for the page, relying on the params method and Rack by default. # It supports all Rack-based frameworks (Sinatra, Padrino, Rails, ...). # For non-rack environments you can use the standalone extra def pagy_url_for(pagy, page, absolute: false, **_) vars = pagy.vars query_params = request.GET.clone query_params.merge!(vars[:params].transform_keys(&:to_s)) if vars[:params].is_a?(Hash) pagy_set_query_params(page, vars, query_params) query_params = vars[:params].(query_params) if vars[:params].is_a?(Proc) query_string = "?#{Rack::Utils.build_nested_query(query_params)}" "#{request.base_url if absolute}#{vars[:request_path] || request.path}#{query_string}#{vars[:fragment]}" end # Add the page and items params # Overridable by the jsonapi extra def pagy_set_query_params(page, vars, query_params) query_params[vars[:page_param].to_s] = page query_params[vars[:items_param].to_s] = vars[:items] if vars[:items_extra] end end end
Version data entries
15 entries across 15 versions & 1 rubygems