Project

leaf

0.01
No commit activity in last 3 years
No release in over 3 years
A really simple pagination library, heavily based on the agnostic branch of will_paginate
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.2.0
 Project Readme

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__

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.)