View Source PhxLocalizedRoutes behaviour (Phoenix Localized Routes v0.1.1)
Macro to create and validate PhxLocalizedRoutes
configuration modules with
convenience callbacks to fetch specific values. For maximum performance, most
callbacks return precompiled values with precomputed additional data.
When used with an app depending on Phoenix.LiveView
it also creates a LiveHelper module.
For information how to use see the Usage Guide
Link to this section Summary
Callbacks
Return a list of unique values assigned to given key. Returns a list of tuples with unique combinations when a list of keys is given.
Returns the configuration with precomputed values and flattened scopes
Returns the scope of given scope helper
Returns the scopes in a flat structure
Returns the scopes in a nested structure
Link to this section Types
@type opts() :: [ scopes: %{required(binary()) => opts_scope()}, gettext_module: module() ]
@type opts_scope() :: %{ optional(:assign) => %{required(atom()) => any()}, optional(:scopes) => %{required(binary()) => opts_scope()} }
Link to this section Callbacks
Return a list of unique values assigned to given key. Returns a list of tuples with unique combinations when a list of keys is given.
Example
iex> ExampleWeb.LocalizedRoutes.assigned_values(:locale)
["en", "nl"]
iex> ExampleWeb.LocalizedRoutes.assigned_values([:locale, :locale])
[{"en", "en-GB"}, {"nl", "nl-NL"}, {"nl", "nl_BE"}]
@callback config() :: PhxLocalizedRoutes.Config.t()
Returns the configuration with precomputed values and flattened scopes
@callback get_scope(scope_helper :: nil | String.t()) :: PhxLocalizedRoutes.Scope.Flat.t()
Returns the scope of given scope helper
@callback scopes() :: %{required(binary() | nil) => PhxLocalizedRoutes.Scope.Flat.t()}
Returns the scopes in a flat structure
@callback scopes_nested() :: %{ required(binary() | nil) => PhxLocalizedRoutes.Scope.Nested.t() }
Returns the scopes in a nested structure