This gem integrates the Bulma pagination component with the will_paginate pagination gem.
gem install will_paginate-bulma
, or- For projects using Bundler, add
gem 'will_paginate-bulma'
to yourGemfile
(and then runbundle install
).
- To work with Hanami, you'll need to bundle a fork of will_paginate at phoffer/will_paginate with the
hanami
branch. (Hopefully it will be merged soon!) - Add the helper to the app you want to use will_paginate in application.rb. This enables will_pagination in Hanami.
- 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 %>
- Load the Bulma CSS in your template.
- In your view, use the
renderer: BulmaPagination::Rails
option with thewill_paginate
helper, for example:
<%= will_paginate @collection, renderer: BulmaPagination::Rails %>
- Load the Bulma CSS in your template.
require "will_paginate-bulma"
in your Sinatra app.- In your view, use the
renderer: BulmaPagination::Sinatra
option with thewill_paginate
helper, for example:
<%= will_paginate @collection, renderer: BulmaPagination::Sinatra %>
Any of the above usage scenarios will accept configuration options, allowing the user to change the pagination components 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 elementlink_separator
text or html to insert between pagination-link elementslink_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 elementnext_label
text or html to replace the inner content of the link within the pagination-next elementmaximum_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.
- Fork it.
- Create a branch (
git checkout -b my_markup
) - Commit your changes (
git commit -am "Cool new feature"
) - Push to the branch (
git push origin my_markup
) - Open a [Pull Request][1]
This gem code was based on will_paginate-foundation by Adrian Rangel (@acrogenesis).
The MIT License (MIT)