use <%= inspect web_module %>, :html
import StarView.Controller, only: [init_signals: 1]
# ======================================================================================
# Layouts
attr :conn, :map, required: true
attr :lang, :string, default: "en"
attr :body_attrs, :map, default: %{}
# Slots
slot :inner_block, required: true
slot :head
@spec app(map()) :: Phoenix.LiveView.Rendered.t()
def app(assigns) do
~H"""
<.root lang={@lang} body_attrs={@body_attrs}>
<:head :if={@head != []}>{render_slot(@head)}
This is the app
{render_slot(@inner_block)}
"""
end
# ======================================================================================
# Root Layout
attr :lang, :string, default: "en"
attr :body_attrs, :map, default: %{}
# Slots
slot :inner_block, required: true
slot :head
defp root(assigns) do
~H"""
<.favicon />
<.app_css />
<.app_js />
<.data_star_js />
{render_slot(@head)}
This is the root!!
{render_slot(@inner_block)}
"""
end
defp favicon(assigns) do
~H"""
"""
end
defp app_css(assigns) do
~H"""
"""
end
defp app_js(assigns) do
~H"""
<.script defer? static? src={~p"/assets/js/app.js"} />
"""
end
defp data_star_js(assigns) do
~H"""
<.script
type="module"
src="https://cdn.jsdelivr.net/gh/starfederation/datastar@v1.0.1/bundles/datastar.js"
/>
"""
end
defp csrf_signal() do
%{"data-signals:csrf" => "'#{get_csrf_token()}'"}
end
attr :src, :string, required: true
attr :type, :string, default: "text/javascript"
attr :defer?, :boolean, default: false
attr :static?, :boolean, default: false
defp script(assigns) do
~H"""
"""
end