Class: RailsPaginate::Renderers::HtmlDefault
- 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
-
#render ⇒ Object
render html for pagination.
-
#render_pager ⇒ Object
render pager.
-
#show_first_page? ⇒ Boolean
show first page item?.
-
#show_last_page? ⇒ Boolean
show last page item?.
-
#show_next_page? ⇒ Boolean
show next page item?.
-
#show_previous_page? ⇒ Boolean
show previous page item?.
Methods inherited from Base
Constructor Details
This class inherits a constructor from RailsPaginate::Renderers::Base
Instance Method Details
#render ⇒ Object
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 content_tag(:ul) do html = "\n" if show_first_page? html += content_tag(:li, :class => "first_page") do link_to_page collection.first_page, 'paginate.first_page_label' end html += "\n" end if show_previous_page? html += content_tag(: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 += content_tag(:li, :class => "next_page") do link_to_page collection.next_page, 'paginate.next_page_label' end html += "\n" end if show_last_page? html += content_tag(: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_pager ⇒ Object
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 += content_tag(: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?
75 76 77 |
# File 'lib/rails_paginate/renderers/html_default.rb', line 75 def show_first_page? [:show_first_page] || self.class.show_first_page end |
#show_last_page? ⇒ Boolean
show last page item?
80 81 82 |
# File 'lib/rails_paginate/renderers/html_default.rb', line 80 def show_last_page? [:show_last_page] || self.class.show_last_page end |
#show_next_page? ⇒ Boolean
show next page item?
85 86 87 |
# File 'lib/rails_paginate/renderers/html_default.rb', line 85 def show_next_page? [:show_next_page] || self.class.show_next_page end |
#show_previous_page? ⇒ Boolean
show previous page item?
90 91 92 |
# File 'lib/rails_paginate/renderers/html_default.rb', line 90 def show_previous_page? [:show_previous_page] || self.class.show_previous_page end |