defmodule Combo.Inertia.HTML do @moduledoc """ The HTML components and helpers for building Inertia views. """ use Combo.HTML @doc """ Renders a `` tag that includes the `inertia` attribute needed for the Inertia client-side library to subsequently manage the page title. The content you provide to this component will only apply to the initial server-rendered response. You will also need to use the [client-side `<Head>` component](https://inertiajs.com/title-and-meta) in your Inertia page components to be sure the the page title is updated when internal navigation occurs. If you are planning to manage page titles from the server-side, you may find it useful to expose the `page_title`: * via regular assigns, so server-side `<.inertia_title>` can use it. * via Inertia page props, so client-side `<Head>` can use it. def index(conn, _params) page_title = "My page title" conn |> assign(:page_title, page_title) |> inertia_put_prop(:page_title, page_title) |> inertia_render("MyPage") end """ @doc type: :component slot :inner_block, required: true, doc: "Content rendered inside the `title` tag." def inertia_title(assigns) do ~CE""" <title inertia> {render_slot(@inner_block)} """ end @doc type: :component attr :content, :list, required: true, doc: "The list of tags to inject into the `head` tag." def inertia_head(assigns) do ~CE""" {raw(Enum.join(@content, "\n"))} """ end @doc false # This
element serves as the mounting point for the JavaScript application. def csr_content(assigns) do ~CE"""
""" end @doc false def ssr_content(assigns) do ~CE""" {raw(@body)} """ end end