View Source Routex.Extension.Interpolation (Phoenix Routes Extension Framework v0.3.0-alpha.4)
A route may be defined with a routes Routex.Attrs
interpolated
into it. These interpolations are specified using the usual #{variable}
interpolation syntax.
In combination with...
This plugin makes a good duo with
Routex.Extension.Alternatives
. You might want to disable auto prefixing for the whole Routex backend (seeRoutex.Extension.Alternatives
) or per route (seeRoutex
for instructions).
Bare base route
The route as specified in the Router will be stripped from any interpolation syntax. This allows you to still use routes without interpolation syntax in your templates, have them verified by Verified Routes while generating routes with interpolated attributes at run time.
Usage
# file /lib/example_web/routes.ex
live "/products/#{locale}/:id", ProductLive.Index, :index
Pseudo result
# in combination with Routex.Extension.Alternatives with auto prefix
# disabled and 3 branches. It splits the routes and sets the :locale
# attribute which is used for interpolation.
⇒ /products/en/:id
/products/:id/ ⇒ /products/fr/:id
⇒ /products/fr/:id
Routex.Attrs
Requires
- none
Sets
- none