Astral.SVG (Astral v0.2.0)

Copy Markdown View Source

Inline server-rendered SVG assets for Astral templates.

SVG files are resolved through Volt asset resolution, parsed as XML, validated to have an <svg> root, and rendered through Phoenix's HTML-safe protocol. This keeps SVG includes narrower than generic raw HTML while still allowing project SVG files such as clip-path definitions to be included directly.

Summary

Functions

Resolve, parse, and return an inline SVG value for the current Astral render.

Render an inline SVG value to iodata.

Types

t()

@type t() :: %Astral.SVG{
  attrs: [{String.t(), term()}],
  children: [tuple()],
  path: String.t()
}

Functions

inline!(src, opts \\ [])

@spec inline!(
  String.t(),
  keyword()
) :: t()

Resolve, parse, and return an inline SVG value for the current Astral render.

to_iodata(svg)

@spec to_iodata(t()) :: iodata()

Render an inline SVG value to iodata.