Skip to content

Commit

Permalink
Merge pull request mgwidmann#40 from mamantoha/patch-1
Browse files Browse the repository at this point in the history
fix pagination_links in README.md
  • Loading branch information
mgwidmann authored Oct 30, 2016
2 parents f410d75 + 0c98b21 commit 85c910a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end
Use in your template.

```elixir
<%= pagination_links @conn, @page %>
<%= pagination_links @page %>
```

Where `@page` is a `%Scrivener.Page{}` struct returned from `Repo.paginate/2`.
Expand Down Expand Up @@ -80,45 +80,45 @@ end
You would need to pass in the `:locale` parameter and `:path` option like so:

```elixir
<%= pagination_links @conn, @page, ["en"], path: &pages_path/4 %>
<%= pagination_links @page, ["en"], path: &pages_path/4 %>
```

With a nested resource, simply add it to the list:

```elixir
<%= pagination_links @conn, @page, ["en", @page_id], path: &page_path/4, action: :show %>
<%= pagination_links @page, ["en", @page_id], path: &page_path/4, action: :show %>
```

#### Query String Parameters

Any additional query string parameters can be passed in as well.

```elixir
<%= pagination_links @conn, @page, ["en"], some_parameter: "data" %>
<%= pagination_links @page, ["en"], some_parameter: "data" %>
<%# OR IF NO URL PARAMETERS %>
<%= pagination_links @conn, @page, some_parameter: "data" %>
<%= pagination_links @page, some_parameter: "data" %>
```

### Custom Actions

If you need to hit a different action other than `:index`, simply pass the action name to use in the url helper.

```elixir
<%= pagination_links @conn, @page, action: :show %>
<%= pagination_links @page, action: :show %>
```

## Customizing Output

Below are the defaults which are used without passing in any options.

```elixir
<%= pagination_links @conn, @page, distance: 5, next: ">>", previous: "<<", first: true, last: true, view_style: :bootstrap %>
<%= pagination_links @page, distance: 5, next: ">>", previous: "<<", first: true, last: true, view_style: :bootstrap %>
```

To prevent HTML escaping (i.e. seeing things like `&lt;` on the page), simply use `Phoenix.HTML.raw/1` for any `&amp;` strings passed in, like so:

```elixir
<%= pagination_links @conn, @page, previous: Phoenix.HTML.raw("&leftarrow;"), next: Phoenix.HTML.raw("&rightarrow;") %>
<%= pagination_links @page, previous: Phoenix.HTML.raw("&leftarrow;"), next: Phoenix.HTML.raw("&rightarrow;") %>
```

There are three view styles currently supported:
Expand Down

0 comments on commit 85c910a

Please sign in to comment.