Last active
June 6, 2020 09:18
-
-
Save tslim/28986f5b52df10fc3d7237fd7d95bfe5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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