class Integral::ButtonLinkRenderer
Foundation pagination with buttons
Public Instance Methods
container_attributes()
click to toggle source
Container attributes
Calls superclass method
# File lib/integral/button_link_renderer.rb, line 25 def container_attributes super.except(:link_options) end
link(text, target, attributes = {})
click to toggle source
Link item
# File lib/integral/button_link_renderer.rb, line 10 def link(text, target, attributes = {}) attributes['data-page'] = target if target.is_a?(Integer) tag(:button, text, attributes) end
to_html()
click to toggle source
Pagination container
# File lib/integral/button_link_renderer.rb, line 16 def to_html list_items = pagination.map do |item| item.is_a?(Integer) ? page_number(item) : send(item) end.join(@options[:link_separator]) tag(:ul, list_items, class: "pagination #{@options[:class]}") end
url(page)
click to toggle source
The URL or page
# File lib/integral/button_link_renderer.rb, line 5 def url(page) page end
Protected Instance Methods
page_number(page)
click to toggle source
# File lib/integral/button_link_renderer.rb, line 31 def page_number(page) link_options = @options[:link_options] || {} if page == current_page tag :li, tag(:span, page), class: 'current' else tag :li, link(page, page, link_options.merge(rel: rel_value(page))) end end
previous_or_next_page(page, text, classname)
click to toggle source
# File lib/integral/button_link_renderer.rb, line 41 def previous_or_next_page(page, text, classname) link_options = @options[:link_options] || {} if page tag :li, link(text, page, link_options), class: classname else tag :li, tag(:span, text), class: format('%s disabled', classname) end end