Module: Pagy::FrontendHelpers::Frontend

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
# File 'lib/pagy/extras/frontend_helpers.rb', line 49

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

Return the marked link to used by pagy.js



64
65
66
# File 'lib/pagy/extras/frontend_helpers.rb', line 64

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