Skip to content

Commit 4b5f68f

Browse files
committed
Simplify layout mentions
1 parent 6b8dad2 commit 4b5f68f

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

guides/server/gettext.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ LiveViews by default:
5353

5454
def live_view do
5555
quote do
56-
use Phoenix.LiveView,
57-
layout: {MyAppWeb.Layouts, :app}
56+
use Phoenix.LiveView
5857

5958
on_mount MyAppWeb.RestoreLocale
6059
unquote(view_helpers())

guides/server/live-layouts.md

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# Live layouts
22

3-
From Phoenix v1.7, your application is made of two layouts:
3+
Your LvieView applications can be made of two layouts:
44

55
* the root layout - this is a layout used by both LiveView and
66
regular views. This layout typically contains the `<html>`
77
definition alongside the head and body tags. Any content defined
88
in the root layout will remain the same, even as you live navigate
99
across LiveViews. The root layout is typically declared on the
1010
router with `put_root_layout` and defined as "root.html.heex"
11-
in your layouts folder
11+
in your layouts folder. It calls `{@inner_content}` to inject the
12+
content rendered by the layout
1213

1314
* the app layout - this is the default application layout which
1415
is rendered on both regular HTTP requests and LiveViews.
15-
It defaults to "app.html.heex"
16+
It defaults to "app.html.heex". This layout is typically set
17+
on `use Phoenix.LiveView, layout: ...` but it has been discouraged
18+
in more recent Phoenix versions, in favor of using explicit function
19+
components as layouts.
1620

1721
Overall, those layouts are found in `components/layouts` and are
1822
embedded within `MyAppWeb.Layouts`.
1923

20-
All layouts must call `{@inner_content}` to inject the
21-
content rendered by the layout.
22-
2324
## Root layout
2425

2526
The "root" layout is rendered only on the initial request and
@@ -31,27 +32,6 @@ is typically defined in your router:
3132
The root layout can also be set via the `:root_layout` option
3233
in your router via `Phoenix.LiveView.Router.live_session/2`.
3334

34-
## Application layout
35-
36-
The "app.html.heex" layout is rendered with either `@conn` or
37-
`@socket`. Both Controllers and LiveViews explicitly define
38-
the default layouts they will use. See the `def controller`
39-
and `def live_view` definitions in your `MyAppWeb` to learn how
40-
it is included.
41-
42-
For LiveViews, the default layout can be overridden in two different
43-
ways for flexibility:
44-
45-
1. The `:layout` option in `Phoenix.LiveView.Router.live_session/2`,
46-
when set, will override the `:layout` option given via
47-
`use Phoenix.LiveView`
48-
49-
2. The `:layout` option returned on mount, via `{:ok, socket, layout: ...}`
50-
will override any previously set layout option
51-
52-
The LiveView itself will be rendered inside the layout wrapped by
53-
the `:container` tag.
54-
5535
## Updating document title
5636

5737
Because the root layout from the Plug pipeline is rendered outside of

guides/server/security-model.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ to run it on all LiveViews by default:
186186

187187
def live_view do
188188
quote do
189-
use Phoenix.LiveView,
190-
layout: {MyAppWeb.Layouts, :app}
189+
use Phoenix.LiveView
191190

192191
on_mount MyAppWeb.UserLiveAuth
193192
unquote(html_helpers())

lib/phoenix_component.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,9 @@ defmodule Phoenix.Component do
969969
* `:sticky` - an optional flag to maintain the LiveView across live redirects, even if it is
970970
nested within another LiveView. Note that this only works for LiveViews that are in the same
971971
[live_session](`Phoenix.LiveView.Router.live_session/3`).
972-
If you are rendering the sticky view within make sure that the sticky view itself does not use
973-
the same layout. You can do so by returning `{:ok, socket, layout: false}` from mount.
972+
If you are rendering the sticky view within another LiveView, make sure that the sticky view
973+
itself does not use the same layout. You can do so by returning `{:ok, socket, layout: false}`
974+
from mount.
974975
975976
## Examples
976977

0 commit comments

Comments
 (0)