Module: Pagy::FrontendHelpers::FrontendAddOn

Included in:
Pagy::Frontend
Defined in:
lib/pagy/extras/frontend_helpers.rb

Overview

Additions for the Frontend

Instance Method Summary collapse

Instance Method Details

#pagy_data(pagy, *args) ⇒ Object

Return a data tag with the base64 encoded JSON-serialized args generated with the slower to_json Base64 encoded JSON is smaller than HTML escaped JSON



49
50
51
52
53
# File 'lib/pagy/extras/frontend_helpers.rb', line 49

def pagy_data(pagy, *args)
  args << pagy.vars[:page_param] if pagy.vars[:trim_extra]
  strict_base64_encoded = [Oj.dump(args, mode: :strict)].pack('m0')
  %(data-pagy="#{strict_base64_encoded}")
end

Return the marked link used by pagy.js



66
67
68
# File 'lib/pagy/extras/frontend_helpers.rb', line 66

def pagy_marked_link(link)
  link.call PAGE_TOKEN, '', 'style="display: none;"'
end