will_paginate is the defacto standard plugin for the Rails community. Almost every app will need pagination and will_paginate does almost everything you need.
The one thing will_paginate does not do is generate semantic pagination markup. Semantic markup uses standard HTML tags to convey structure and meaning. For example using an
h1 tag for a heading rather than styling a
div tag to do the same.
The default will_paginate pagination is a series of anchors and spans strung together. As many a designer has pointed out, that series is really a list of pagination controls. If you are working with such a designer or you are writing semantic markup, try out my fork and enjoy will_paginate with semantic pagination.
As of this moment, you can install it as a plugin. I am considering releasing this as a gem; ideally the patch to will_paginate would be accepted (see below).
%script/plugin install git://github.com/leshill/will_paginate.git
will_paginate view helper, passing the
:semantic => true option. If you do not want the enclosing
ul tag, pass
:container => false.
<%= will_paginate @pages, :semantic => true %>
Which looks like:
1<ul class="pagination"> 2 <li class="disabled prev_page">« Previous</li> 3 <li class="current">1</li> 4 <li><a href="/pages?page=2" rel="next">2</a></li> 5 <li><a href="/pages?page=3">3</a></li> 6 <li><a href="/pages?page=4">4</a></li> 7 <li><a href="/pages?page=5">5</a></li> 8 <li><a href="/pages?page=6">6</a></li> 9 <li><a href="/pages?page=7">7</a></li> 10 <li><a href="/pages?page=8">8</a></li> 11 <li><a href="/pages?page=9">9</a></li> 12 <li class="gap">…</li> 13 <li><a href="/pages?page=33">33</a></li> 14 <li><a href="/pages?page=34">34</a></li> 15 <li class="next_page"><a href="/pages?page=2" class="next_page" rel="next">Next »</a></li> 16</ul>
Signs point to ‘uncertain’. Mislav has in the past indicated that he was not convinced that list support was necessary in the plugin since you can replace the renderer1. Since semantic markup is commonly used, I have sent a pull request. In any event, the authors of will_paginate have my thanks for creating a very useful plugin.