mirror of
https://github.com/woutdp/live_svelte
synced 2026-05-24 09:28:21 +00:00
added to README usage section
This commit is contained in:
parent
f62731295a
commit
cb57b77303
1 changed files with 18 additions and 0 deletions
18
README.md
18
README.md
|
|
@ -169,6 +169,24 @@ end
|
|||
|
||||
If your component is in a directory, for example `assets/svelte/some-directory/SomeComponent.svelte` you need to include the directory in your name: `some-directory/SomeComponent`.
|
||||
|
||||
### The Components Macro
|
||||
|
||||
There is also an Elixir macro which checks your `assets/svelte` folder for any Svelte components, and injects local function `def`s for those components into the calling module.
|
||||
|
||||
This allows for an alternative, more JSX-like authoring experience inside Liveviews.
|
||||
|
||||
e.g. in the below example, a Svelte component called `Example` is available to be called inside the Liveview template:
|
||||
|
||||
```elixir
|
||||
use LiveSvelte.Components
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<.Example number={@number} />
|
||||
"""
|
||||
end
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
Examples can be found in the `/examples` and `/example_project` directories.
|
||||
|
|
|
|||
Loading…
Reference in a new issue