Skip to content

Instantly share code, notes, and snippets.

@isaacbowen
Created August 30, 2011 21:37
Show Gist options
  • Select an option

  • Save isaacbowen/1182136 to your computer and use it in GitHub Desktop.

Select an option

Save isaacbowen/1182136 to your computer and use it in GitHub Desktop.

Revisions

  1. isaacbowen revised this gist Aug 30, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions will_paginate.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # config/initializers/will_paginate.rb

    module WillPaginate
    module ActionView
    def will_paginate(collection = nil, options = {})
  2. isaacbowen created this gist Aug 30, 2011.
    24 changes: 24 additions & 0 deletions will_paginate.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    module WillPaginate
    module ActionView
    def will_paginate(collection = nil, options = {})
    options[:renderer] ||= BootstrapLinkRenderer
    super.try :html_safe
    end

    class BootstrapLinkRenderer < LinkRenderer
    protected

    def html_container(html)
    tag :div, tag(:ul, html), container_attributes
    end

    def page_number(page)
    tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
    end

    def previous_or_next_page(page, text, classname)
    tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
    end
    end
    end
    end