Skip to content

Commit

Permalink
Fix example without Repo in README
Browse files Browse the repository at this point in the history
I was a bit confused reading the README for this repo, so I made a couple of edits which hopefully clarifies the usage:

* Added a binding to the missing `page` variable in the first example.
* `Usage without a Repo module` now no longer references a `Repo` module.
  • Loading branch information
mbuhot authored Aug 28, 2017
1 parent 6d968c8 commit 68039b2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ library is also being used in the project and gives access to the pre-configured
def index(conn, params) do
config = maybe_put_default_config(params)

["C#", "C++", "Clojure", "Elixir", "Erlang", "Go", "JAVA", "JavaScript", "Lisp",
"PHP", "Perl", "Python", "Ruby", "Rust", "SQL"]
|> Enum.map(&(&1 <> " " <> "language"))
|> Scrivener.paginate(config)
page =
["C#", "C++", "Clojure", "Elixir", "Erlang", "Go", "JAVA", "JavaScript", "Lisp",
"PHP", "Perl", "Python", "Ruby", "Rust", "SQL"]
|> Enum.map(&(&1 <> " " <> "language"))
|> Scrivener.paginate(config)

render conn, :index,
people: page.entries,
Expand All @@ -59,10 +60,10 @@ defp maybe_put_default_config(_params), do: %Scrivener.Config{page_number: 1, pa
list = ["C#", "C++", "Clojure", "Elixir", "Erlang", "Go", "JAVA", "JavaScript", "Lisp",
"PHP", "Perl", "Python", "Ruby", "Rust", "SQL"]

MyApp.Repo.paginate(list, %Scrivener.Config{page_number: 1, page_size: 4}) # %Scrivener.Config{}
MyApp.Repo.paginate(list, page: 1, page_size: 4) # keyword list
MyApp.Repo.paginate(%{page: 1, page_size: 4}) # map
MyApp.Repo.paginate(%{page: 1}) # map with only page number (page_size defaults to 10)
Scrivener.paginate(list, %Scrivener.Config{page_number: 1, page_size: 4}) # %Scrivener.Config{}
Scrivener.paginate(list, page: 1, page_size: 4) # keyword list
Scrivener.paginate(list, %{page: 1, page_size: 4}) # map
Scrivener.paginate(list, %{page: 1}) # map with only page number (page_size defaults to 10)
```


Expand Down

0 comments on commit 68039b2

Please sign in to comment.