Kerosene v0.6.0 Kerosene.HTML

Html helpers to render the pagination links and more, import the Kerosene.HTML in your view module.

defmodule MyApp.ProductView do
  use MyApp.Web, :view
  import Kerosene.HTML
end

now you have these view helpers in your template file.

<%= paginate @conn, @page %>

Where @page is a %Kerosene{} struct returned from Repo.paginate/2.

paginate helper takes keyword list of options and params. <%= paginate @conn, @page, window: 5, next_label: “>>”, previous_label: “<<”, first: true, last: true, first_label: “First”, last_label: “Last” %>

Summary

Macros

Generates the HTML pagination links for a given page returned by Kerosene

Functions

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

Macros

__using__(opts \\ [])

Generates the HTML pagination links for a given page returned by Kerosene.

The theme indicates which CSS framework you are using. The default is :bootstrap, but you can add your own using the Kerosene.HTML.do_paginate/3 function if desired. Kerosene provides few themes out of the box:

[:bootstrap, :bootstrap4, :foundation, :semantic]

Example:

iex> Kerosene.HTML.paginate(@conn, @kerosene)

Path can be overriden by adding setting :path in the opts. For example:

Kerosene.HTML.paginate(@conn, @kerosene, path: product_path(@conn, :index, foo: "bar"))

Additional panigation class can be added by adding setting :class in the opts. For example:

Kerosene.HTML.paginate(@conn, @kerosene, theme: :boostrap4, class: "paginate-sm")