Module | WillPaginate::ActionView |
In: |
lib/will_paginate/view_helpers/action_view.rb
|
This module serves for availability in ActionView templates. It also adds a new view helper: paginated_section.
If the helper is called without passing in the collection object, it will try to read from the instance variable inferred by the controller name. For example, calling will_paginate while the current controller is PostsController will result in trying to read from the @posts variable. Example:
<%= will_paginate :id => true %>
… will result in @post collection getting paginated:
<div class="pagination" id="posts_pagination"> ... </div>
Wrapper for rendering pagination links at both top and bottom of a block of content.
<% paginated_section @posts do %> <ol id="posts"> <% for post in @posts %> <li> ... </li> <% end %> </ol> <% end %>
will result in:
<div class="pagination"> ... </div> <ol id="posts"> ... </ol> <div class="pagination"> ... </div>
Arguments are passed to a will_paginate call, so the same options apply. Don‘t use the :id option; otherwise you‘ll finish with two blocks of pagination links sharing the same ID (which is invalid HTML).