From cb57b77303ab8fd41ab4d5c8d9afc9c7fb2ff5f4 Mon Sep 17 00:00:00 2001 From: Conor Sinclair Date: Sun, 28 May 2023 20:06:03 +0100 Subject: [PATCH] added to README usage section --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index a3bc411..6b11d33 100644 --- a/README.md +++ b/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.