phoenix_live_view v0.6.0-dev Phoenix.LiveView.Router View Source
Provides LiveView routing for Phoenix routers.
Link to this section Summary
Functions
Defines a LiveView route.
Link to this section Functions
Defines a LiveView route.
Layout
When a layout isn't explicitly set, a default layout is inferred similar to
controller actions. For example, the layout for the router MyAppWeb.Router
would be inferred as MyAppWeb.LayoutView
and would use the :app
template.
Options
:session
- a map of strings keys and values to be merged into the session:layout
- the optional tuple for specifying a layout to render the LiveView. Defaults to{LayoutView, :app}
where LayoutView is relative to your application's namespace.:container
- the optional tuple for the HTML tag and DOM attributes to be used for the LiveView container. For example:{:li, style: "color: blue;"}
. SeePhoenix.LiveView.live_render/3
for more information on examples.:as
- optionally configures the named helper. Defaults to:live
.
Examples
defmodule MyApp.Router
use Phoenix.Router
import Phoenix.LiveView.Router
scope "/", MyApp do
pipe_through [:browser]
live "/thermostat", ThermostatLive
live "/clock", ClockLive
live "/dashboard", DashboardLive, layout: {MyApp.AlternativeView, "app.html"}
end
end
iex> MyApp.Router.Helpers.live_path(MyApp.Endpoint, MyApp.ThermostatLive)
"/thermostat"