) }
- %(#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(Trim) && pagy.vars[:page_param])})
+ %(#{pagy_json_tag(pagy, :nav, id, tags, pagy.sequels)})
end
# Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -48,7 +48,7 @@ def pagy_bootstrap_combo_nav_js(pagy, id=pagy_id)
html << %(
),
'after' => '' }
- %(#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(Trim) && pagy.vars[:page_param])})
+ %(#{pagy_json_tag(pagy, :nav, id, tags, pagy.sequels)})
end
# Javascript combo pagination for Bulma: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -53,7 +53,7 @@ def pagy_bulma_combo_nav_js(pagy, id=pagy_id)
html << %(
)) \
+ '' ) }
- %(#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(Trim) && pagy.vars[:page_param])})
+ %(#{pagy_json_tag(pagy, :nav, id, tags, pagy.sequels)})
end
# Javascript combo pagination for materialize: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -52,7 +52,7 @@ def pagy_materialize_combo_nav_js(pagy, id=pagy_id)
html << %(
)) }
- %(#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(Trim) && pagy.vars[:page_param])})
+ %(#{pagy_json_tag(pagy, :nav, id, tags, pagy.sequels)})
end
# Combo pagination for semantic: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -48,7 +48,7 @@ def pagy_semantic_combo_nav_js(pagy, id=pagy_id)
html << %(
))
- html << %(#{pagy_json_tag(:combo_nav, id, p_page, pagy_marked_link(link), defined?(Trim) && pagy.vars[:page_param])})
+ html << %(#{pagy_json_tag(pagy, :combo_nav, id, p_page, pagy_marked_link(link))})
end
end
diff --git a/lib/pagy/extras/shared.rb b/lib/pagy/extras/shared.rb
index d071f726f..57c1d3b76 100644
--- a/lib/pagy/extras/shared.rb
+++ b/lib/pagy/extras/shared.rb
@@ -27,11 +27,17 @@ 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] )
+ %()
+ 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] )
+ %()
+ end
end
# it returns the SHA1 (fastest on modern ruby) string used as default `id` attribute by all the `*_js` tags
diff --git a/lib/pagy/extras/uikit.rb b/lib/pagy/extras/uikit.rb
index 3c69a16b6..12b762567 100644
--- a/lib/pagy/extras/uikit.rb
+++ b/lib/pagy/extras/uikit.rb
@@ -38,7 +38,7 @@ def pagy_uikit_nav_js(pagy, id=pagy_id)
'gap' => %(
#{pagy_json_tag(pagy, :nav, id, tags, pagy.sequels)})
end
# Javascript combo pagination for uikit: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -56,7 +56,7 @@ def pagy_uikit_combo_nav_js(pagy, id=pagy_id)
html << (p_next ? link.call(p_next, pagy_t('pagy.nav.next'), 'class="uk-button uk-button-default"')
: %())
- html << %(#{pagy_json_tag(:combo_nav, id, p_page, pagy_marked_link(link), defined?(Trim) && pagy.vars[:page_param])})
+ html << %(#{pagy_json_tag(pagy, :combo_nav, id, p_page, pagy_marked_link(link))})
end
end
end
diff --git a/test/pagy/extras/shared_test.rb b/test/pagy/extras/shared_test.rb
index 7d33e011e..adbf62ab8 100644
--- a/test/pagy/extras/shared_test.rb
+++ b/test/pagy/extras/shared_test.rb
@@ -17,8 +17,8 @@
describe "#pagy_json_tag" do
it 'should use oj' do
- _(view.pagy_json_tag(:test_function, 'some-id', 'some-string', 123, true)).must_equal \
- ""
+ _(view.pagy_json_tag(Pagy.new(count: 10), :test_function, 'some-id', 'some-string', 123, true)).must_equal \
+ ""
end
end