Method: Pagy::FoundationExtra#pagy_foundation_nav
- Defined in:
- lib/pagy/extras/foundation.rb
#pagy_foundation_nav(pagy, pagy_id: nil, link_extra: '', **vars) ⇒ Object
Pagination for Foundation: it returns the html with the series of links to the pages
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pagy/extras/foundation.rb', line 11 def pagy_foundation_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-foundation-nav" aria-label="Pagination"><ul class="pagination">) html << pagy_foundation_prev_html(pagy, link) pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] html << case item when Integer then %(<li>#{link.call item}</li>) # page link when String then %(<li class="current">#{pagy.label_for(item)}</li>) # active page when :gap then %(<li class="ellipsis gap" aria-hidden="true"></li>) # page gap else raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}" end end html << pagy_foundation_next_html(pagy, link) html << %(</ul></nav>) end |