Class: MerbPaginate::LinkRenderer
- Inherits:
-
Object
- Object
- MerbPaginate::LinkRenderer
- Defined in:
- lib/merb_paginate/view_helpers.rb
Overview
Copied mostly from will_paginate, but changed to work with the merb url helpers
Instance Method Summary collapse
- #html_attributes ⇒ Object
- #html_attributes_string ⇒ Object
-
#initialize(collection, options, template) ⇒ LinkRenderer
constructor
A new instance of LinkRenderer.
- #to_html ⇒ Object
Constructor Details
#initialize(collection, options, template) ⇒ LinkRenderer
Returns a new instance of LinkRenderer.
151 152 153 154 155 |
# File 'lib/merb_paginate/view_helpers.rb', line 151 def initialize(collection, , template) @collection = collection @options = @template = template end |
Instance Method Details
#html_attributes ⇒ Object
167 168 169 170 171 172 173 174 175 |
# File 'lib/merb_paginate/view_helpers.rb', line 167 def html_attributes return @html_attributes if @html_attributes @html_attributes = @options.except *(MerbPaginate::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 |
#html_attributes_string ⇒ Object
177 178 179 180 181 182 183 184 185 |
# File 'lib/merb_paginate/view_helpers.rb', line 177 def html_attributes_string string = "" if html_attributes html_attributes.each do |key, value| string << " #{key}='#{value}'" end end string end |
#to_html ⇒ Object
157 158 159 160 161 162 163 164 165 |
# File 'lib/merb_paginate/view_helpers.rb', line 157 def to_html links = @options[:page_links] ? windowed_links : [] # previous/next buttons links.unshift page_link_or_span(@collection.previous_page, 'disabled', @options[:prev_label]) links.push page_link_or_span(@collection.next_page, 'disabled', @options[:next_label]) html = links.join(@options[:separator]) @options[:container] ? "<div#{html_attributes_string}>#{html}</div>" : html end |