Skip to content

Commit

Permalink
Docs tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 29, 2022
1 parent 15ec572 commit 62c02b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions lib/phoenix_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ defmodule Phoenix.Component do
@moduledoc ~S'''
Define reusable function components with HEEx templates.
A function component is any function that receives an assigns map as an argument and returns
a rendered struct built with [the `~H` sigil](`sigil_H/2`):
A function component is any function that receives an assigns
map as an argument and returns a rendered struct built with
[the `~H` sigil](`sigil_H/2`):
defmodule MyComponent do
use Phoenix.Component
Expand All @@ -27,8 +28,8 @@ defmodule Phoenix.Component do
<p>Hello, Jane!</p>
```
If the function component is defined locally, or its module is imported, then the caller can
invoke the function directly without specifying the module:
If the function component is defined locally, or its module is imported,
then the caller can invoke the function directly without specifying the module:
```heex
<.greet name="Jane" />
Expand All @@ -48,11 +49,9 @@ defmodule Phoenix.Component do
</.card>
```
Like `Phoenix.LiveView` and `Phoenix.LiveComponent`, function components are implemented using
a map of assigns, and follow [the same rules and best practices](../guides/server/assigns-eex.md).
However, we typically do not implement function components by manipulating the assigns map
directly, as `Phoenix.Component` provides two higher-level abstractions for us:
attributes and slots.
Note how the `name` attribute automatically becomes the `@name` assign inside
function components. This can be further leveraged by using two higher-level
abstractions for us: attributes and slots.
## Attributes
Expand Down
4 changes: 2 additions & 2 deletions lib/phoenix_live_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ defmodule Phoenix.LiveView do
template, which stands for HTML+EEx. They are an extension of Elixir's
builtin EEx templates, with support for HTML validation, syntax-based
components, smart change tracking, and more. You can learn more about
the template syntax in `Phoenix.Component.sigil_H/2` (note all
`Phoenix.Component` is imported when you use `Phoenix.LiveView`).
the template syntax in `Phoenix.Component.sigil_H/2` (note
`Phoenix.Component` is automatically imported when you use `Phoenix.LiveView`).
Next, decide where you want to use your LiveView.
Expand Down

0 comments on commit 62c02b0

Please sign in to comment.