Combo.Router.Helpers (combo v0.8.0)
View SourceGenerates a module for named routes helpers and generic url helpers.
Named routes helpers exist to avoid hardcoding routes, if you wrote
<a href="/login"> and then changed your router, the link would point to a
page that no longer exist. By using router helpers, you can make sure it
always points to a valid URL in your router.
Generic url helpers exist for convenience.
Examples
defmodule MyApp.Web.Router do
use Combo.Router
# ...
endIt will generated a module named MyApp.Web.Router.Helpers, and following
functions are available.
Name routes helpers:
*_url/_*_path/_
Generic url helpers:
url/_path/_static_url/_static_path/_static_integrity/_
Forwarded routes
Forwarded routes are also resolved automatically. For example, imagine you have a forward path to an admin router in your main router:
defmodule MyApp.Web.Router do
# ...
forward "/admin", MyApp.Web.AdminRouter
end
defmodule MyApp.Web.AdminRouter do
# ...
get "/users", MyApp.Web.Admin.UserController
end
Summary
Functions
Receives a route and returns the quoted definition for its helper function.
Generates the helper module for the given environment and routes.
Callback for generate router catch all.
Functions
Receives a route and returns the quoted definition for its helper function.
In case a helper name was not given, or route is forwarded, returns nil.
Generates the helper module for the given environment and routes.
Callback for generate router catch all.