Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshdholtz/html-pager
HTML Pager
https://github.com/joshdholtz/html-pager
Last synced: 10 days ago
JSON representation
HTML Pager
- Host: GitHub
- URL: https://github.com/joshdholtz/html-pager
- Owner: joshdholtz
- Created: 2013-04-22T14:06:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-04-23T14:20:29.000Z (over 11 years ago)
- Last Synced: 2024-10-11T10:33:06.066Z (about 1 month ago)
- Language: Ruby
- Size: 145 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
endget '/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 %>
````