A really simple pagination library, heavily based on the agnostic branch of will_paginate.

Installation

gem install leaf

Example usage

require 'rubygems'
require 'sinatra'
require 'leaf'

include Leaf::ViewHelpers::Base

# Needed to paginate any array, 
# you’ll probably use something else.
require 'leaf/array'

get '/' do
  page = (params[:page]) ? params[:page] : 1
  array = ('a'..'z').to_a
  
  haml :index, :locals => { 
    :collection => array.paginate({
      :page => page, 
      :per_page => 5
    }) 
  }
end

__END__
@@ index
= leaf(collection)
%ul
  - collection.each do |letter|
    %li= letter
Fork me on GitHub