You could try scopes that pipe through different Router plugs like what @silverdr was doing.
defmodule HelloWeb.Router do
use HelloWeb, :router
pipeline :guest_layout do
plug :put_layout, [html: {HelloWeb.LayoutView, :guest}]
end
pipeline :admin_layout do
plug :put_layout, [html: {HelloWeb.LayoutView, :admin}]
end
scope "/guest", HelloWeb do
pipe_through [:guest_layout]
live "/feed", HelloWeb.FeedLive, :index
live "/status", HelloWeb.StatusLive, :index
live "/status/:id", HelloWeb.StatusLive, :show
end
scope "/admin", HelloWeb do
pipe_through [:admin_layout]
live "/admin", HelloWeb.AdminDashboardLive, :index
live "/admin/posts", HelloWeb.AdminPostLive, :index
end
end
Poking around the LiveView docs, I see there’s also a live_session/3 function for grouping together live routes into a session for live redirects which happens to accept an optional layout in the form of “a tuple with the view module and template string or atom name”.
defmodule HelloWeb.Router do
use HelloWeb, :router
live_session :guest, layout: {HelloWeb.LayoutView, :guest} do
live "/feed", HelloWeb.FeedLive, :index
live "/status", HelloWeb.StatusLive, :index
live "/status/:id", HelloWeb.StatusLive, :show
end
live_session :admin, layout: {HelloWeb.LayoutView, :admin} do
live "/admin", HelloWeb.AdminDashboardLive, :index
live "/admin/posts", HelloWeb.AdminPostLive, :index
end
end