View Source Surface.LiveView (surface v0.11.4)
A wrapper component around Phoenix.LiveView
.
Since this module is just a wrapper around Phoenix.LiveView
, you
cannot define custom properties for it. Only :id
and :session
are available. However, built-in directives like :for
and :if
can be used normally.
Example
defmodule Example do
use Surface.LiveView
def render(assigns) do
~F"""
<Dialog title="Alert" id="dialog">
This <b>Dialog</b> is a stateful component. Cool!
</Dialog>
<Button click="show_dialog">Click to open the dialog</Button>
"""
end
def handle_event("show_dialog", _, socket) do
Dialog.show("dialog")
{:noreply, socket}
end
end