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.
150 151 152 153 154 |
# File 'lib/merb_paginate/view_helpers.rb', line 150 def initialize(collection, , template) @collection = collection = @template = template end |
Instance Method Details
#html_attributes ⇒ Object
166 167 168 169 170 171 172 173 174 |
# File 'lib/merb_paginate/view_helpers.rb', line 166 def html_attributes return @html_attributes if @html_attributes @html_attributes = .except *(MerbPaginate::ViewHelpers..keys - [:class]) # pagination of Post models will have the ID of "posts_pagination" if [:container] and [:id] === true @html_attributes[:id] = @collection.first.class.name.underscore.pluralize + '_pagination' end @html_attributes end |
#html_attributes_string ⇒ Object
176 177 178 179 180 181 182 183 184 |
# File 'lib/merb_paginate/view_helpers.rb', line 176 def html_attributes_string string = "" if html_attributes html_attributes.each do |key, value| string << " #{key}='#{value}'" end end string end |
#to_html ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/merb_paginate/view_helpers.rb', line 156 def to_html links = [:page_links] ? windowed_links : [] # previous/next buttons links.unshift page_link_or_span(@collection.previous_page, 'disabled', [:prev_label]) links.push page_link_or_span(@collection.next_page, 'disabled', [:next_label]) html = links.join([:separator]) [:container] ? "<div#{html_attributes_string}>#{html}</div>" : html end |