woutdp / live_svelte

Svelte inside Phoenix LiveView with seamless end-to-end reactivity
https://hexdocs.pm/live_svelte
MIT License
1.02k stars 38 forks source link

Use sigil for rendering Svelte Component #3

Closed woutdp closed 1 year ago

woutdp commented 1 year ago

I'd love to be able to just do the following and render Svelte directly from a LiveComponent:

defmodule App.LiveComponent do
  use LiveSvelte.LiveComponent

  attr(:foo, :string, default: "")
  attr(:bar, :string)

  def render(assigns) do
    ~v"""
    <script>
        export let foo = "foo";
        export let bar = "bar"
        export let pushEvent;
    </script>

    <h1>It's working!</h1>
    """
  end
end
woutdp commented 1 year ago

Not sure if this is actually that useful, will not do for now