View Source Routex.Extension.AlternativeGetters (Phoenix Routes Extension Framework v0.2.0-alpha.8)
Creates helper functions to get a list of alternative slugs and their routes attributes given a binary url or a list of path segments and a binary url.
configuration
Configuration
# file /lib/example_web/routex_backend.ex
defmodule ExampleWeb.RoutexBackend do
use Routex,
extensions: [
+ Routex.Extension.AlternativeGetters,
],
routex-attrs
Routex.Attrs
Requires
- none
Sets
- none
helpers
Helpers
- alternatives(url :: String.t()) :: struct()
- alternatives(segments :: list, query:: String.t()) :: structs()
Example
iex> ExampleWeb.Router.RoutexHelpers.alternatives("/products/12?foo=baz")
[
%Routex.Extension.AlternativeGetters{
slug: "/europe/products/12/?foo=baz",
attrs: %{
__line__: 32,
__order__: [0, 12, 1],
__origin__: "/products/:id"
}},
%Routex.Extension.AlternativeGetters{
slug: "/asia/products/12/?foo=baz",
attrs: %{
__line__: 32,
__order__: [0, 12, 1],
__origin__: "/products/:id"
}},
]