class Showbuilder::ShowPaginateRenderer

Public Instance Methods

to_html() click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 6
def to_html
  links = @options[:page_links] ? windowed_links : []

  links.unshift(page_link_or_span(@collection.previous_page, 'prev', @options[:previous_label]))
  links.push(page_link_or_span(@collection.next_page, 'next', @options[:next_label]))

  html = links.join(@options[:link_separator])

  html_content = @template.content_tag(:div, :class => :pagination) do
    @template.content_tag(:ul, html.html_safe)
  end
  @options[:container] ? html_content : html
end

Protected Instance Methods

gap_marker() click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 54
def gap_marker
  @template.will_paginate_translate(:page_gap) { '…' }
end
page_span(page, text, attributes = {}) click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 48
def page_span(page, text, attributes = {})
  @template.content_tag :li, attributes do
    @template.content_tag(:a, text)
  end
end
previous_or_next_page(page) click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 58
def previous_or_next_page(page)
  if @collection.current_page <= 1 && @collection.current_page - 1 <= 0
    return page_span(page, @options[:previous_label], :class => "prev disabled")
  end

  if @collection.current_page <= @collection.total_pages && @collection.current_page + 1 >= @collection.total_pages
    return page_span(page, @options[:next_label], :class => "next disabled")
  end
end