lib/pagy/extras/bulma.rb in pagy-5.3.1 vs lib/pagy/extras/bulma.rb in pagy-5.4.0

- old
+ new

@@ -6,18 +6,18 @@ class Pagy # :nodoc: # Frontend modules are specially optimized for performance. # The resulting code may not look very elegant, but produces the best benchmarks module BulmaExtra # Pagination for Bulma: it returns the html with the series of links to the pages - def pagy_bulma_nav(pagy, pagy_id: nil, link_extra: '') + def pagy_bulma_nav(pagy, pagy_id: nil, link_extra: '', **vars) p_id = %( id="#{pagy_id}") if pagy_id link = pagy_link_proc(pagy, link_extra: link_extra) html = +%(<nav#{p_id} class="pagy-bulma-nav pagination is-centered" aria-label="pagination">) html << pagy_bulma_prev_next_html(pagy, link) html << %(<ul class="pagination-list">) - pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] + pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] html << case item when Integer %(<li>#{link.call item, pagy.label_for(item), %(class="pagination-link" aria-label="goto page #{item}")}</li>) when String %(<li>#{link.call item, pagy.label_for(item), @@ -28,11 +28,11 @@ end end html << %(</ul></nav>) end - def pagy_bulma_nav_js(pagy, pagy_id: nil, link_extra: '', steps: nil) + def pagy_bulma_nav_js(pagy, pagy_id: nil, link_extra: '', **vars) p_id = %( id="#{pagy_id}") if pagy_id link = pagy_link_proc(pagy, link_extra: link_extra) tags = { 'before' => %(#{pagy_bulma_prev_next_html(pagy, link)}<ul class="pagination-list">), 'link' => %(<li>#{link.call PAGE_PLACEHOLDER, LABEL_PLACEHOLDER, %(class="pagination-link" aria-label="goto page #{PAGE_PLACEHOLDER}")}</li>), @@ -41,10 +41,10 @@ PAGE_PLACEHOLDER}")}</li>), 'gap' => %(<li><span class="pagination-ellipsis">#{pagy_t 'pagy.nav.gap'}</span></li>), 'after' => '</ul>' } %(<nav#{p_id} class="pagy-njs pagy-bulma-nav-js pagination is-centered" aria-label="pagination" #{ - pagy_json_attr(pagy, :nav, tags, (sequels = pagy.sequels(steps)), pagy.label_sequels(sequels))}></nav>) + pagy_json_attr(pagy, :nav, tags, (sequels = pagy.sequels(**vars)), pagy.label_sequels(sequels))}></nav>) end # Javascript combo pagination for Bulma: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript def pagy_bulma_combo_nav_js(pagy, pagy_id: nil, link_extra: '') p_id = %( id="#{pagy_id}") if pagy_id