lib/pagy/extras/shared.rb in pagy-3.14.0 vs lib/pagy/extras/shared.rb in pagy-4.0.0
- old
+ new
@@ -25,29 +25,27 @@
module Frontend
if defined?(Oj)
# it returns a script tag with the JSON-serialized args generated with the faster oj gem
- def pagy_json_tag(*args)
+ def pagy_json_tag(pagy, *args)
+ args << ( defined?(Trim) && pagy.vars[:page_param] )
%(<script type="application/json" class="pagy-json">#{Oj.dump(args, mode: :strict)}</script>)
end
else
require 'json'
# it returns a script tag with the JSON-serialized args generated with the slower to_json
- def pagy_json_tag(*args)
+ def pagy_json_tag(pagy, *args)
+ args << ( defined?(Trim) && pagy.vars[:page_param] )
%(<script type="application/json" class="pagy-json">#{args.to_json}</script>)
end
end
# it returns the SHA1 (fastest on modern ruby) string used as default `id` attribute by all the `*_js` tags
- def pagy_id
- "pagy-#{Digest::SHA1.hexdigest(caller(2..2)[0].split(':in')[0])}"
- end
+ def pagy_id = "pagy-#{Digest::SHA1.hexdigest(caller(2..2)[0].split(':in')[0])}"
# it returns the marked link to used by pagy.js
- def pagy_marked_link(link)
- link.call(PAGE_PLACEHOLDER, '', 'style="display: none;"')
- end
+ def pagy_marked_link(link) = link.call(PAGE_PLACEHOLDER, '', 'style="display: none;"')
end
end