Class: RailsPaginate::Renderers::HtmlDefault

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_paginate/renderers/html_default.rb

Overview

default html renderer

Constant Summary collapse

@@show_first_page =
true
@@show_last_page =
true
@@show_next_page =
true
@@show_previous_page =
true

Instance Attribute Summary

Attributes inherited from Base

#collection, #options, #pager, #view

Instance Method Summary collapse

Methods inherited from Base

#initialize, #url_for_page

Constructor Details

This class inherits a constructor from RailsPaginate::Renderers::Base

Instance Method Details

#renderObject

render html for pagination



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rails_paginate/renderers/html_default.rb', line 22

def render
  (:ul) do
    html = "\n"

    if show_first_page?
      html += (:li, :class => "first_page") do
        link_to_page collection.first_page, 'paginate.first_page_label'
      end
      html += "\n"
    end

    if show_previous_page?
      html += (:li, :class => "previous_page") do
        link_to_page collection.previous_page, 'paginate.previous_page_label'
      end
      html += "\n"
    end

    html += render_pager

    if show_next_page?
      html += (:li, :class => "next_page") do
        link_to_page collection.next_page, 'paginate.next_page_label'
      end
      html += "\n"
    end

    if show_last_page?
      html += (:li, :class => "last_page") do
        link_to_page collection.last_page, 'paginate.last_page_label'
      end
      html += "\n"
    end
    html.html_safe
  end
end

#render_pagerObject

render pager



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rails_paginate/renderers/html_default.rb', line 60

def render_pager
  view.reset_cycle(:paginate)

  html = ""
  visible_pages = pager.visible_pages
  visible_pages.each do |page|
    html += (:li, :class => "pager #{visible_pages.first == page ? 'first_pager' : ''} #{visible_pages.last == page ? 'last_pager' : ''} #{view.cycle("pager_even", "pager_odd", :name => :paginate)}") do
      link_to_page page, page.nil? ? nil : 'paginate.pager'
    end
    html += "\n"
  end
  html.html_safe
end

#show_first_page?Boolean

show first page item?

Returns:

  • (Boolean)


75
76
77
# File 'lib/rails_paginate/renderers/html_default.rb', line 75

def show_first_page?
  options[:show_first_page] || self.class.show_first_page
end

#show_last_page?Boolean

show last page item?

Returns:

  • (Boolean)


80
81
82
# File 'lib/rails_paginate/renderers/html_default.rb', line 80

def show_last_page?
  options[:show_last_page] || self.class.show_last_page
end

#show_next_page?Boolean

show next page item?

Returns:

  • (Boolean)


85
86
87
# File 'lib/rails_paginate/renderers/html_default.rb', line 85

def show_next_page?
  options[:show_next_page] || self.class.show_next_page
end

#show_previous_page?Boolean

show previous page item?

Returns:

  • (Boolean)


90
91
92
# File 'lib/rails_paginate/renderers/html_default.rb', line 90

def show_previous_page?
  options[:show_previous_page] || self.class.show_previous_page
end