Class: Paginate::Renderer::List

Inherits:
Base
  • Object
show all
Defined in:
lib/paginate/renderer/list.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #processor, #view_context

Instance Method Summary collapse

Methods inherited from Base

#initialize, #next_url, #previous_url, #url_for

Constructor Details

This class inherits a constructor from Paginate::Renderer::Base

Instance Method Details

#next_labelObject



8
9
10
# File 'lib/paginate/renderer/list.rb', line 8

def next_label
  I18n.t("paginate.next")
end

#page_labelObject



12
13
14
# File 'lib/paginate/renderer/list.rb', line 12

def page_label
  I18n.t("paginate.page", page: processor.page)
end

#previous_labelObject



4
5
6
# File 'lib/paginate/renderer/list.rb', line 4

def previous_label
  I18n.t("paginate.previous")
end

#renderObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/paginate/renderer/list.rb', line 16

def render
  html = String.new

  css = %w[ paginate ]
  css << "disabled" unless processor.previous_page? || processor.next_page?

  html << %[<ul class="#{css.join(" ")}">]

  # Previous page
  if processor.previous_page?
    html << %[<li class="previous-page"><a href="#{previous_url}" title="#{previous_label}">#{previous_label}</a></li>]
  else
    html << %[<li class="previous-page disabled"><span title="#{previous_label}">#{previous_label}</span></li>]
  end

  # Current page
  html << %[<li class="page"><span>#{page_label}</span></li>]

  # Next page
  if processor.next_page?
    html << %[<li class="next-page"><a href="#{next_url}" title="#{next_label}">#{next_label}</a></li>]
  else
    html << %[<li class="next-page disabled"><span title="#{next_label}">#{next_label}</span></li>]
  end

  html << %[</ul>]

  html.html_safe
end