Module: Pagy::JSTools::FrontendAddOn

Included in:
Frontend
Defined in:
lib/pagy/extras/js_tools.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



52
53
54
55
56
# File 'lib/pagy/extras/js_tools.rb', line 52

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