module WillPaginate::ActionView
def infer_collection_from_controller
def infer_collection_from_controller collection_name = "@#{controller.controller_name}" collection = instance_variable_get(collection_name) raise ArgumentError, "The #{collection_name} variable appears to be empty. Did you " + "forget to pass the collection object for will_paginate?" if collection.nil? collection end
def page_entries_info(collection = nil, options = {}) #:nodoc:
def page_entries_info(collection = nil, options = {}) #:nodoc: options, collection = collection, nil if collection.is_a? Hash collection ||= infer_collection_from_controller super(collection, options.symbolize_keys) end
def paginated_section(*args, &block)
apply. Don't use the :id option; otherwise you'll finish with two
Arguments are passed to a will_paginate call, so the same options
...
...
...
will result in:
<% end %>
<% end %>
<% for post in @posts %>
<%= paginated_section @posts do %>
of content.
Wrapper for rendering pagination links at both top and bottom of a block
def paginated_section(*args, &block) pagination = will_paginate(*args) if pagination pagination + capture(&block) + pagination else capture(&block) end end
def will_paginate(collection = nil, options = {}) #:nodoc:
def will_paginate(collection = nil, options = {}) #:nodoc: options, collection = collection, nil if collection.is_a? Hash collection ||= infer_collection_from_controller options = options.symbolize_keys options[:renderer] ||= LinkRenderer super(collection, options) end
def will_paginate_translate(keys, options = {})
def will_paginate_translate(keys, options = {}) if respond_to? :translate if Array === keys defaults = keys.dup key = defaults.shift else defaults = nil key = keys end translate(key, **options.merge(:default => defaults, :scope => :will_paginate)) else super end end