Skip to content

Document the available options for will_paginate in the README. #274

Closed
wants to merge 1 commit into from

2 participants

@sodabrew
sodabrew commented Nov 4, 2012

Advanced will_paginate use

The will_paginate view method accepts a number of optional arguments. For example:

<%= will_paginate @events, :previous_label => "Older events", :next_label => "Newer events" %>

Full list of 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' %>

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

Another view method is page_entries_info. It renders a message containing number of displayed vs. total entries.

<%= page_entries_info @posts %>

# Output:
Displaying posts 6 - 12 of 26 in total

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

@mislav
Owner
mislav commented Jan 10, 2013

I've put it on the wiki instead.

@mislav mislav closed this Jan 10, 2013
@sodabrew

Thanks, but putting it in the README is better. Then I can check out the code, go away from Internet access, and still be able to read the documentation while I work on some code.

@mislav
Owner
mislav commented Jan 10, 2013

If you've checked out the code, then you can look at the docs in source code comments ;)

@sodabrew

Ok fair enough :) By the way, thank you for renewing your efforts on this gem! Lots of great updates today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.