Module: Folio::WillPaginate::ViewHelpers::LinkRenderer
- Defined in:
- lib/folio/will_paginate/view_helpers/link_renderer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #link_with_folio(text, target, attributes = {}) ⇒ Object
- #next_page_with_folio ⇒ Object
- #previous_page_with_folio ⇒ Object
- #rel_value_with_folio(page) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/folio/will_paginate/view_helpers/link_renderer.rb', line 43 def self.included(klass) [:previous_page, :next_page, :link, :rel_value].each do |method| klass.send(:alias_method, :"#{method}_without_folio", method) klass.send(:alias_method, method, :"#{method}_with_folio") end end |
Instance Method Details
#link_with_folio(text, target, attributes = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/folio/will_paginate/view_helpers/link_renderer.rb', line 19 def link_with_folio(text, target, attributes = {}) if target # the non-folio version only does this for Fixnums, but we want to # do it for any page value. fortunately, this method only ever # receives Fixnums or nil, so we can do it now for any non-nil # value, and the non-folio version will happily avoid a double # application because even when the page was a fixnum, it won't be # anymore. attributes[:rel] = rel_value(target) target = url(target) end link_without_folio(text, target, attributes) end |
#next_page_with_folio ⇒ Object
13 14 15 16 17 |
# File 'lib/folio/will_paginate/view_helpers/link_renderer.rb', line 13 def next_page_with_folio # the page identifier may not be ordinal; use the value as set on the # collection, instead. previous_or_next_page(@collection.next_page, @options[:next_label], 'next_page') end |
#previous_page_with_folio ⇒ Object
7 8 9 10 11 |
# File 'lib/folio/will_paginate/view_helpers/link_renderer.rb', line 7 def previous_page_with_folio # the page identifier may not be ordinal; use the value as set on the # collection, instead. previous_or_next_page(@collection.previous_page, @options[:previous_label], 'previous_page') end |
#rel_value_with_folio(page) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/folio/will_paginate/view_helpers/link_renderer.rb', line 33 def rel_value_with_folio(page) # don't check against mathed out values, just check the values on the # collection rels = [] rels << 'prev' if page == @collection.previous_page rels << 'next' if page == @collection.next_page rels << 'start' if page == @collection.first_page rels.empty? ? nil : rels.join(' ') end |