Skip to content

Instantly share code, notes, and snippets.

@twined
Last active August 29, 2015 14:11
Show Gist options
  • Save twined/e8305f2f8ceec10853ed to your computer and use it in GitHub Desktop.
Save twined/e8305f2f8ceec10853ed to your computer and use it in GitHub Desktop.
Phoenix Pagination
# in template
<%= next_page_path({:user_path, [:index]}, @current_page, @conn.params %>
# in view
def next_page_path({cur_path, helper_args}, cur_page, params \\ []) do
params = Dict.merge(params, %{"page" => cur_page + 1})
apply(MyApp.Router.Helpers, cur_path, helper_args ++ [params])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment