View Source Routex.Extension.AttrGetters (Routex v1.1.0)
Creates helper functions to get the Routex.Attrs
given a binary url or a
list of path segments. Use this to lazy load attributes instead of adding them
upfront to assigns.
This extension provides the required attrs/1
helper function, used by
Routex to assign helper attributes in the generated on_mount/4
callback.
In combination with...
Other extensions set Routex.Attrs
. The attributes an extension sets is listed in it's documentation.
To define custom attributes for routes have a look at Routex.Extension.Alternatives
Configuration
# file /lib/example_web/routex_backend.ex
defmodule ExampleWeb.RoutexBackend do
use Routex.Backend,
extensions: [
+ Routex.Extension.AttrGetters, # required
],
Pseudo result
iex> ExampleWeb.Router.RoutexHelpers.attrs("/europe/nl/producten/?foo=baz")
%{
__branch__: [0, 9, 3],
__origin__: "/products",
backend: ExampleWeb.LocalizedRoutes,
contact: "verkoop@example.nl",
locale: "nl",
branch_name: "The Netherlands",
branch_helper: "europe_nl",
}
Routex.Attrs
Requires
- none
Sets
- none
Helpers
- attrs(url :: binary) :: map()
- attrs(segments :: list) :: map()