Kerosene
Pagination for Ecto and Phoenix.
Installation
The package is available in Hex, the package can be installed as:
-
Add kerosene to your list of dependencies in
mix.exs:def deps do [{:kerosene, "~> 0.1.0"}] end
-
Add Kerosene to your
repo.ex:defmodule Testapp.Repo do use Ecto.Repo, otp_app: :testapp use Kerosene, per_page: 2 end
-
You can start paginating your queries
def index(conn, params) do {products, kerosene} = Product |> Product.active |> Repo.paginate(params)
render(conn, "index.html", products: products, kerosene: kerosene)end
-
Add view helpers to your view
defmodule MyApp.ProductView do use MyApp.Web, :view import Kerosene.HTML end
-
Generate the links using the view helpers
<%= paginate @conn, @kerosene %>
Note: you can also send in opts for the helper look at the docs for more details
Contributing
Please do send pull requests and bug reports, positive feedback is always welcome.
Acknowledgements
I would like to Thanks
* Matt (@mgwidmann)
* Drew Olson (@drewolson)
* Akira Matsuda (@amatsuda)
License
Please take a look at LICENSE.md