View Source Torch.PaginationView (Torch v4.1.0)

Phoenix.View to render pagination controls for Torch-generated index templates.

Link to this section Summary

Functions

The resource name, as an atom, for this view

Generates a "Next >" link to the next page of results. The link is only returned if there is another page.

Generates a "< Prev" link to the previous page of results. The link is only returned if there is a previous page.

Renders the given template locally.

Callback invoked when no template is found. By default it raises but can be customized to render a particular template.

Link to this section Functions

The resource name, as an atom, for this view

Link to this function

next_link(conn, current_page, num_pages, sort_opts \\ nil)

View Source

Generates a "Next >" link to the next page of results. The link is only returned if there is another page.

Examples

iex> next_link(%Plug.Conn{params: %{}}, 1, 2) |> safe_to_string()
"<a href=\"?page=2\">Next &gt;</a>"

iex> next_link(%Plug.Conn{}, 2, 2)
nil
Link to this function

prev_link(conn, current_page, sort_opts \\ nil)

View Source

Generates a "< Prev" link to the previous page of results. The link is only returned if there is a previous page.

Examples

iex> prev_link(%Plug.Conn{params: %{}}, 2) |> safe_to_string()
"<a href=\"?page=1\">&lt; Prev</a>"

If the current page is 1, returns nil:

iex> prev_link(%Plug.Conn{params: %{}}, 1)
nil
Link to this function

render(template, assigns \\ %{})

View Source

Renders the given template locally.

Link to this function

template_not_found(template, assigns)

View Source

Specs

template_not_found(Phoenix.Template.name(), map()) :: no_return()

Callback invoked when no template is found. By default it raises but can be customized to render a particular template.