Index: lib/will_paginate/view_helpers.rb =================================================================== --- lib/will_paginate/view_helpers.rb (revision 389) +++ lib/will_paginate/view_helpers.rb (working copy) @@ -39,11 +39,17 @@ # All extra options are passed to the generated container DIV, so eventually # they become its HTML attributes. # - def will_paginate(entries = @entries, options = {}) + # If the links that will_paginate generates aren't what you want, then you can + # pass a block for generating the links. For example: + # + # will_paginate(@books) do |page, text| + # link_to("Page #{text}!", :controller => 'books', :action => 'whatever', :page => (page != 1 ? page : nil)) + # end + def will_paginate(entries = @entries, options = {}, &link_render_proc) total_pages = if entries.page_count > 1 - renderer = WillPaginate::LinkRenderer.new entries, options, self + renderer = WillPaginate::LinkRenderer.new entries, options, self, &link_render_proc links = renderer.items content_tag :div, links, renderer.html_options @@ -56,10 +62,11 @@ # directly (for now) because its API is not set in stone yet. class LinkRenderer - def initialize(collection, options, template) + def initialize(collection, options, template, &link_render_proc) @collection = collection @options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options @template = template + @link_render_proc = link_render_proc end def items @@ -114,8 +121,12 @@ unless page @template.content_tag :span, text, :class => span_class else - # page links should preserve GET/POST parameters - @template.link_to text, @template.params.merge(param => page != 1 ? page : nil) + if @link_render_proc + @link_render_proc.call(page, text) + else + # page links should preserve GET/POST parameters + @template.link_to text, @template.params.merge(param => page != 1 ? page : nil) + end end end