Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joshdholtz/html-pager

HTML Pager
https://github.com/joshdholtz/html-pager

Last synced: 10 days ago
JSON representation

HTML Pager

Awesome Lists containing this project

README

        

# Example using Sinatra with HAML and ERB templating

## Installation - Gemfile
```` ruby
gem 'html_pager', :git => 'git://github.com/joshdholtz/html-pager.git'
````

## Quick Use

```` ruby

require 'html_pager'

# Initializes pager with paging information
@pager = HTMLPager::Pager.new(:route => "/search", :current_page => page.to_i, :show_n_pages => 5, :total_page_count => 10)

# Returns the HTML in the format below
@pager.to_s

````

## HTML Generated
```` html

````

## With Bootstrap
![Imgur](http://i.imgur.com/lcyr6c4.png)

## Without Bootstrap
![Imgur](http://i.imgur.com/f5pfQz0.png)

```` ruby

require 'sinatra'
require 'html_pager'

enable :inline_templates

get '/haml-example' do
page = params[:page]
page = 1 unless page

@pager = HTMLPager::Pager.new(:route => "/haml-example", :page_param_name => "page", :previous_page => "Back yo", :next_page => "Forward yo", :current_page => page.to_i, :show_n_pages => 5, :total_page_count => 10)

haml :haml_example
end

get '/erb-example' do
page = params[:page]
page = 1 unless page

@pager = HTMLPager::Pager.new(:route => "/erb-example", :page_param_name => "page", :previous_page => "Back yo", :next_page => "Forward yo", :current_page => page.to_i, :show_n_pages => 5, :total_page_count => 10)

erb :erb_example
end

__END__

@@ haml_example
%html

:css
.pagination a.current-page { font-weight: bold; }

%body
This is an example

%div= @pager

@@ erb_example


.pagination a.current-page { font-weight: bold; }


This is an example


<%= @pager %>

````