defmodule FirehoseWeb.Layouts do @moduledoc """ This module holds layouts and related functionality used by your application. """ use FirehoseWeb, :html # Embed all files in layouts/* within this module. # The default root.html.heex file contains the HTML # skeleton of your application, namely HTML headers # and other static content. embed_templates "layouts/*" @doc """ Stores content in the connection for later rendering in layouts. Used to inject dynamic meta tags into the `
` section. """ def put_content_for(conn, key, content) do content_for = Map.get(conn.assigns, :content_for, %{}) new_content_for = Map.update(content_for, key, [content], &(&1 ++ [content])) Plug.Conn.assign(conn, :content_for, new_content_for) end @doc """ Retrieves content stored via `put_content_for/3`. Can be called from HEEx templates with `get_content_for(assigns, :meta_tags)`. """ def get_content_for(assigns, key) do content_for = assigns[:content_for] if is_map(content_for), do: Map.get(content_for, key, []), else: [] end @doc """ Shows the flash group with standard titles and content. ## Examples <.flash_group flash={@flash} /> """ attr :flash, :map, required: true, doc: "the map of flash messages" attr :id, :string, default: "flash-group", doc: "the optional id of flash container" def flash_group(assigns) do ~H"""