Skip to content

Instantly share code, notes, and snippets.

@shishirsharma
Forked from isaacbowen/will_paginate.rb
Last active December 22, 2015 03:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shishirsharma/6410029 to your computer and use it in GitHub Desktop.
Save shishirsharma/6410029 to your computer and use it in GitHub Desktop.
Works with Bootstrap 3 and Will_paginate 3.0.4 and Sinatra
# gist https://gist.github.com/expertmind/6410029
# Based on https://gist.github.com/isaacbowen/1182136
module WillPaginate
module Sinatra
module Helpers
include ViewHelpers
def will_paginate(collection, options = {}) #:nodoc:
options = options.merge(:renderer => BootstrapLinkRenderer) unless options[:renderer]
super(collection, options)
end
end
class BootstrapLinkRenderer < LinkRenderer
protected
def html_container(html)
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
def gap
tag :li, link(super, '#'), :class => 'disabled'
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment