Class: WillPaginate::ViewHelpers::LinkRenderer
- Inherits:
-
LinkRendererBase
- Object
- LinkRendererBase
- WillPaginate::ViewHelpers::LinkRenderer
- Defined in:
- lib/will_paginate/view_helpers/link_renderer.rb
Overview
This class does the heavy lifting of actually building the pagination links. It is used by will_paginate
helper internally.
Instance Method Summary collapse
-
#container_attributes ⇒ Object
Returns the subset of
options
this instance was initialized with that represent HTML attributes for the container element of pagination links. -
#prepare(collection, options, template) ⇒ Object
-
collection
is a WillPaginate::Collection instance or any other object that conforms to that API *options
are forwarded fromwill_paginate
view helper *template
is the reference to the template being rendered.
-
-
#to_html ⇒ Object
Process it! This method returns the complete HTML string which contains pagination links.
Methods inherited from LinkRendererBase
Instance Method Details
#container_attributes ⇒ Object
Returns the subset of options
this instance was initialized with that represent HTML attributes for the container element of pagination links.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/will_paginate/view_helpers/link_renderer.rb', line 36 def container_attributes @container_attributes ||= begin 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 attributes[:id] = @collection.first.class.name.underscore.pluralize + '_pagination' end attributes end end |
#prepare(collection, options, template) ⇒ Object
-
collection
is a WillPaginate::Collection instance or any other object that conforms to that API -
options
are forwarded fromwill_paginate
view helper -
template
is the reference to the template being rendered
15 16 17 18 19 |
# File 'lib/will_paginate/view_helpers/link_renderer.rb', line 15 def prepare(collection, , template) super(collection, ) @template = template @container_attributes = @base_url_params = 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.
24 25 26 27 28 29 30 31 32 |
# File 'lib/will_paginate/view_helpers/link_renderer.rb', line 24 def to_html html = pagination.map do |item| item.is_a?(Fixnum) ? page_number(item) : send(item) end.join(@options[:separator]) @options[:container] ? html_container(html) : html end |