Class: WillPaginate::LinkRenderer
- Inherits:
-
Object
- Object
- WillPaginate::LinkRenderer
- Includes:
- I18n
- Defined in:
- lib/will_paginate/view_helpers.rb
Overview
This class does the heavy lifting of actually building the pagination links. It is used by the will_paginate helper internally.
Constant Summary collapse
- CURRENT_CLASS_NAME =
'current'
Instance Attribute Summary collapse
-
#gap_marker ⇒ Object
writeonly
DEPRECATED.
Instance Method Summary collapse
-
#html_attributes ⇒ Object
Returns the subset of
optionsthis instance was initialized with that represent HTML attributes for the container element of pagination links. -
#prepare(collection, options, template) ⇒ Object
-
collectionis a WillPaginate::Collection instance or any other object that conforms to that API *optionsare forwarded fromwill_paginateview helper *templateis the reference to the template being rendered.
-
-
#to_html ⇒ Object
Process it! This method returns the complete HTML string which contains pagination links.
Methods included from I18n
append_translations_load_path, #gap_marker, #next_label, #page_entries_info, #previous_label
Instance Attribute Details
#gap_marker=(value) ⇒ Object (writeonly)
DEPRECATED. See WillPaginate::I18n.
The gap in page links is represented by:
…
205 206 207 |
# File 'lib/will_paginate/view_helpers.rb', line 205 def gap_marker=(value) @gap_marker = value end |
Instance Method Details
#html_attributes ⇒ Object
Returns the subset of options this instance was initialized with that represent HTML attributes for the container element of pagination links.
235 236 237 238 239 240 241 242 243 |
# File 'lib/will_paginate/view_helpers.rb', line 235 def html_attributes return @html_attributes if @html_attributes @html_attributes = @options.except *(WillPaginate::ViewHelpers..keys - [:class]) # pagination of Post models will have the ID of "posts_pagination" if @options[:container] and @options[:id] === true @html_attributes[:id] = @collection.first.class.name.underscore.pluralize + '_pagination' end @html_attributes end |
#prepare(collection, options, template) ⇒ Object
-
collectionis a WillPaginate::Collection instance or any other object that conforms to that API -
optionsare forwarded fromwill_paginateview helper -
templateis the reference to the template being rendered
211 212 213 214 215 216 217 218 |
# File 'lib/will_paginate/view_helpers.rb', line 211 def prepare(collection, , template) @collection = collection @options = @template = template # reset values in case we're re-using this instance @total_pages = @param_name = @url_string = nil end |
#to_html ⇒ Object
Process it! This method returns the complete HTML string which contains pagination links. Feel free to subclass LinkRenderer and change this method as you see fit.
223 224 225 226 227 228 229 230 231 |
# File 'lib/will_paginate/view_helpers.rb', line 223 def to_html links = @options[:page_links] ? windowed_links : [] # previous/next buttons links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', previous_label) links.push page_link_or_span(@collection.next_page, 'disabled next_page', next_label) html = links.join(@options[:separator]) @options[:container] ? @template.content_tag(:div, html, html_attributes) : html end |