Kerosene v0.9.0 Kerosene.JSON View Source
JSON helpers to render the pagination links in json format.
import the Kerosene.JSON
in your view module.
defmodule MyApp.ProductView do
use MyApp.Web, :view
import Kerosene.JSON
def render("index.json", %{conn: conn, products: products, kerosene: kerosene}) do
%{data: render_many(products, MyApp.ProductView, "product.json"),
pagination: paginate(conn, kerosene)}
end
end
Where kerosene
is a %Kerosene{}
struct returned from Repo.paginate/2
.
paginate
helper takes keyword list of options
.
paginate(kerosene, window: 5, next_label: “>>”, previous_label: “<<”, first: true, last: true, first_label: “First”, last_label: “Last”)