Because I constantly work with designers, who prefer to have their own pagination markup customized to their heart's content. Current problems I have:
- It is very hard for me to change the markup with the current libraries out there.
- No Ohm / Redis support available (as far as I know).
- NIH?
This is currently streamlined for use with:
- Sinatra
- Ohm
- HAML
require 'rubygems'
require 'sinatra'
require 'pagination'
helpers Pagination::Helpers
get '/items' do
# Let's say current_user returns a User model with an items method
@items = paginate current_user.items, :page => params[:page]
haml :'items/index'
end
# then in your view index.haml
!= pagination @items
pagination haml
# Spits out the pagination haml markup that's being used
# Or if you prefer erb, you can also do that too...
pagination erb
# Then you can just use it as a partial
pagination haml > app/views/pagination.haml
# in your view
!= partial :pagination, :items => @items