module FoundationPagination::FoundationRenderer

Contains functionality shared by all renderer classes.

Public Instance Methods

container_attributes() click to toggle source
Calls superclass method
# File lib/foundation_pagination/foundation_renderer.rb, line 15
def container_attributes
  super.except(*[:link_options])
end
to_html() click to toggle source
# File lib/foundation_pagination/foundation_renderer.rb, line 7
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

Protected Instance Methods

gap() click to toggle source
# File lib/foundation_pagination/foundation_renderer.rb, line 40
def gap
  tag :li, '', :class => 'ellipsis'
end
next_page() click to toggle source
# File lib/foundation_pagination/foundation_renderer.rb, line 49
def next_page
  num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
  previous_or_next_page(num, @options[:next_label], "pagination-next")
end
page_number(page) click to toggle source
# File lib/foundation_pagination/foundation_renderer.rb, line 21
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/foundation_pagination/foundation_renderer.rb, line 31
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 => "%s disabled" % classname
  end
end
previous_page() click to toggle source
# File lib/foundation_pagination/foundation_renderer.rb, line 44
def previous_page
  num = @collection.current_page > 1 && @collection.current_page - 1
  previous_or_next_page(num, @options[:previous_label], "pagination-previous")
end