https://github.com/phoffer/will_paginate-bulma
Integrates the Bulma pagination component with will_paginate
https://github.com/phoffer/will_paginate-bulma
ruby will-paginate
Last synced: about 1 year ago
JSON representation
Integrates the Bulma pagination component with will_paginate
- Host: GitHub
- URL: https://github.com/phoffer/will_paginate-bulma
- Owner: phoffer
- License: mit
- Created: 2017-07-01T05:28:56.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T00:21:16.000Z (about 3 years ago)
- Last Synced: 2025-03-09T05:39:23.991Z (over 1 year ago)
- Topics: ruby, will-paginate
- Language: Ruby
- Size: 47.9 KB
- Stars: 4
- Watchers: 0
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.markdown
- License: MIT-LICENSE
Awesome Lists containing this project
README
# will_paginate-bulma

This gem integrates the [Bulma](http://bulma.io) [pagination component](http://bulma.io/documentation/components/pagination/) with the [will_paginate](https://github.com/mislav/will_paginate) pagination gem.
## Supports Bulma 0.4.2-0.9.0
## Install
* `gem install will_paginate-bulma`, *or*
* For projects using Bundler, add `gem 'will_paginate-bulma'` to your `Gemfile` (and then run `bundle install`).
## Usage
### Hanami
1. To work with Hanami, you'll need to bundle a fork of will_paginate at [phoffer/will_paginate](https://github.com/phoffer/will_paginate) with the `hanami` branch. (Hopefully it will be merged soon!)
2. Add the helper to the app you want to use will_paginate in application.rb. This enables will_pagination in Hanami.
3. To render, use `BulmaPagination::Hanami` as the renderer.
```
# apps/web/application.rb
view.prepare do
...
include WillPaginate::Hanami
end
# rendering
<%= will_paginate collection, renderer: BulmaPagination::Hanami %>
```
### Rails
1. Load the Bulma CSS in your template.
2. In your view, use the `renderer: BulmaPagination::Rails` option with the `will_paginate` helper, for example:
```
<%= will_paginate @collection, renderer: BulmaPagination::Rails %>
```
### Sinatra
1. Load the Bulma CSS in your template.
2. `require "will_paginate-bulma"` in your Sinatra app.
3. In your view, use the `renderer: BulmaPagination::Sinatra` option with the `will_paginate` helper, for example:
```
<%= will_paginate @collection, renderer: BulmaPagination::Sinatra %>
```
## Configuration
Any of the above usage scenarios will accept configuration options, allowing the user to change the [pagination components](https://bulma.io/documentation/components/pagination/) appearance with Bulma modifier classes. For example, the following will render the pagination component centered on the page:
```
<%= will_paginate @collection, renderer: BulmaPagination::Rails, class: 'is-centered' %>
```
The supported configuration options are as follows:
* `class` applies a class to the top level pagination nav element
* `link_separator` text or html to insert between pagination-link elements
* `link_options` a hash of attributes added to active pagination-link elements _(note, classes added here will be overwritten)_
* `previous_label` text or html to replace the inner content of the link within the pagination-previous element
* `next_label` text or html to replace the inner content of the link within the pagination-next element
* `maximum_links` affect how spacers are applied when you have many pages. This allows you to show the first and last page, then the current page with a certain number of pages on either sides.

Contributing
------------
1. Fork it.
2. Create a branch (`git checkout -b my_markup`)
3. Commit your changes (`git commit -am "Cool new feature"`)
4. Push to the branch (`git push origin my_markup`)
5. Open a [Pull Request][1]
### Special Thanks
This gem code was based on [will_paginate-foundation](https://github.com/acrogenesis/will_paginate-foundation) by Adrian Rangel ([@acrogenesis](https://github.com/acrogenesis)).
License
------------
The MIT License (MIT)