scrivener_html_semi v3.0.1 Scrivener.HTML View Source

Usage

Import Scrivener.HTML to your view:

defmodule SampleWeb.UserView do
  use SampleWeb, :view
  use Scrivener.HTML
end

Use helper functions in your template:

<%= pagination @page %>

Where @page is a %Scrivener.Page{} struct.

Read Scrivener.HTML.pagination for more details.

SEO

See Scrivener.HTML.SEO for more details.

Link to this section Summary

Functions

Generates the HTML pagination for a given %Scrivener.Page{} returned by Scrivener.

Link to this section Functions

Link to this function

pagination(page, options \\ [])

View Source

Generates the HTML pagination for a given %Scrivener.Page{} returned by Scrivener.

Available options

Available options consists of options provided by Scrivener.HTML.Parse and Scrivener.HTML.Render.

Default options of Scrivener.HTML.Parse:

[
  range: 5,
  prev: "PREV",
  next: "NEXT",
  first?: true,
  last?: true,
  ellipsis: {:safe, "&hellip;"}
]

Default options of Scrivener.HTML.Render:

[
  render_module: Scrivener.HTML.Render.Preset,
  html_attrs: [],
  hide_single: false,
  path: "",
  page_param: :page
]

All other options will be considered as extra params of links.

Examples

Call pagination/2 with Scrivener.HTML.Parse options:

iex> pagination(%Scrivener.Page{total_pages: 10, page_number: 5}, distance: 4)

Call pagination/2 with more options:

iex> pagination(%Scrivener.Page{total_pages: 10, page_number: 5}, page_param: :p, distance: 4)

Call pagination/2 with extra options:

iex> pagination(%Scrivener.Page{total_pages: 10, page_number: 5}, my_param: "foobar")

Custom HTML output

Custom HTML attrs of container

iex> pagination(%Scrivener.Page{total_pages: 10, page_number: 5}, html_attrs: [class: "pagination"])

Custom previous and next buttons

iex> pagination(%Scrivener.Page{total_pages: 10, page_number: 5}, previous: Phoenix.HTML.raw("&leftarrow;"), next: Phoenix.HTML.raw("&rightarrow;")

Advanced customization

Create a render module referencing Scrivener.HTML.Render.Preset, then use it by setting :render_module option.