Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple pagination library based on the agnostic branch of will_paginate
Ruby
Tree: c3e09ad51c

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
MIT-LICENSE
README.rdoc
Rakefile
leaf.gemspec

README.rdoc

Leaf

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

Description

Leaf supports pagination for collections responding to total_pages, per_page, previous_page and total_entries in Sinatra views out of the box.

It currently supports two renderers: +Leaf::ViewHelpers::LinkRenderer+ and +Leaf::ViewHelpers::ListRenderer+

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, :renderer => Leaf::ViewHelpers::ListRenderer)
%ul
  - collection.each do |letter|
    %li= letter

Authors and credits

Leaf is based on will_paginate which was originally written by PJ Hyett, who later handed over development to Mislav Marohnić. (The library was completely rewritten since then.)

Something went wrong with that request. Please try again.