Module WillPaginate::ViewHelpers
In: lib/will_paginate/view_helpers.rb
lib/will_paginate/view_helpers/link_renderer.rb
lib/will_paginate/view_helpers/link_renderer_base.rb

Will Paginate view helpers

The main view helper is will_paginate. It renders the pagination links for the given collection. The helper itself is lightweight and serves only as a wrapper around LinkRenderer instantiation; the renderer then does all the hard work of generating the HTML.

Methods

Included Modules

WillPaginate::I18n

Classes and Modules

Class WillPaginate::ViewHelpers::LinkRenderer
Class WillPaginate::ViewHelpers::LinkRendererBase

Attributes

pagination_options  [RW]  Write to this hash to override default options on the global level:
  WillPaginate::ViewHelpers.pagination_options[:page_links] = false

Public Instance methods

Renders a message containing number of displayed vs. total entries.

  <%= page_entries_info @posts %>
  #-> Displaying posts 6 - 12 of 26 in total

The default output contains HTML. Use ":html => false" for plain text.

Returns HTML representing page links for a WillPaginate::Collection-like object. In case there is no more than one page in total, nil is returned.

Options

  • :class — CSS class name for the generated DIV (default: "pagination")
  • :previous_label — default: "« Previous"
  • :next_label — default: "Next »"
  • :page_links — when false, only previous/next links are rendered (default: true)
  • :inner_window — how many links are shown around the current page (default: 4)
  • :outer_window — how many links are around the first and the last page (default: 1)
  • :link_separator — string separator for page HTML elements (default: single space)
  • :param_name — parameter name for page number in URLs (default: :page)
  • :params — additional parameters when generating pagination links (eg. :controller => "foo", :action => nil)
  • :renderer — class name, class or instance of a link renderer (default in Rails: WillPaginate::ActionView::LinkRenderer)
  • :page_links — when false, only previous/next links are rendered (default: true)
  • :container — toggles rendering of the DIV container for pagination links, set to false only when you are rendering your own pagination markup (default: true)

All options not recognized by will_paginate will become HTML attributes on the container element for pagination links (the DIV). For example:

  <%= will_paginate @posts, :style => 'color:blue' %>

will result in:

  <div class="pagination" style="color:blue"> ... </div>

[Validate]