Phoenix.Pagination.JSON (phoenix_pagination v0.7.0) View Source

JSON helpers to render the pagination links in json format. import the Phoenix.Pagination.JSON in your view module.

defmodule MyApp.ProductView do
  use MyApp.Web, :view
  import Phoenix.Pagination.JSON

  def render("index.json", %{conn: conn, products: products, phoenix_pagination: phoenix_pagination}) do
    %{data: render_many(products, MyApp.ProductView, "product.json"),
      pagination: paginate(conn, phoenix_pagination)}
  end
end

Where phoenix_pagination is a %Phoenix.Pagination{} struct returned from Repo.paginate/2.

paginate helper takes keyword list of options. paginate(phoenix_pagination, window: 5, next_label: ">>", previous_label: "<<", first: true, last: true, first_label: "First", last_label: "Last")

Link to this section Summary

Link to this section Functions

Link to this function

paginate(conn, paginator, opts \\ [])

View Source
Link to this function

render_page_list(page_list)

View Source