PhoenixMountable.Layout (PhoenixMountable v0.2.1)

Copy Markdown View Source

Components for a library's root layout, and a ready-made root layout.

A library with a document of its own (layout: {MyLib.Layouts, :root}) renders the tags its page needs with these components:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <PhoenixMountable.Layout.meta mount={@mount} />
    <PhoenixMountable.Layout.assets mount={@mount} />
    <.live_title>{assigns[:page_title] || "My Lib"}</.live_title>
  </head>
  <body>{@inner_content}</body>
</html>

Or it uses layout: {PhoenixMountable.Layout, :root}, which renders that, titled after the :title option of use PhoenixMountable.

Libraries without LiveView use PhoenixMountable.HTML in EEx templates.

Summary

Functions

Tags for the mount's asset entries, with the request's CSP nonces and phx-track-static.

The <meta> tags the library's JavaScript reads: the CSRF token, the LiveView socket path and transport, and the mount path. The browser helper PhoenixMountable.connect() reads them.

A complete root layout: meta tags, assets and a title.

Functions

assets(assigns)

Tags for the mount's asset entries, with the request's CSP nonces and phx-track-static.

Attributes

  • mount (PhoenixMountable.Mount) (required)
  • only (:list) - the entry names to render, all by default. Defaults to nil.

meta(assigns)

The <meta> tags the library's JavaScript reads: the CSRF token, the LiveView socket path and transport, and the mount path. The browser helper PhoenixMountable.connect() reads them.

Attributes

root(assigns)

A complete root layout: meta tags, assets and a title.