Skip to content

Instantly share code, notes, and snippets.

@tslim
Last active June 6, 2020 09:18
Show Gist options
  • Save tslim/28986f5b52df10fc3d7237fd7d95bfe5 to your computer and use it in GitHub Desktop.
Save tslim/28986f5b52df10fc3d7237fd7d95bfe5 to your computer and use it in GitHub Desktop.
# Set root layout in pipeline
defmodule MyApp.Router do
pipeline :browser do
...
plug :put_root_layout, {MyApp.LayoutView, :root}
...
# Set root layout in routes
scope "/", MyApp do
live "/dashboard", MyApp.Dashboard, layout: {MyApp.LayoutView, :root}
# Custom live layout in myapp_web.ex
def custom_live_view do
quote do
use Phoenix.LiveView, layout: {MyApp.LayoutView, "custom_live.html"}
unquote(view_helpers())
end
end
# Use custom_live_view in LiveView
defmodule MyApp.UserLive.Index do
use MyApp, :custom_live_view
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment