Converts a canvas spec + binding values into a clean SVG string
suitable for rasterization by rsvg-convert / librsvg.
Why we generate fresh SVG instead of reusing the editor's HEEx output:
- The editor uses
<foreignObject>to embed HTML for ergonomic text layout. librsvg ignoresforeignObject, so we generate native<text>+<tspan>here with manual word wrapping. - The editor renders a 60%-scaled preview; the rasterizer needs the
full-size SVG (the canvas's intrinsic
width/height).
The output is deterministic — same canvas + values produce
byte-identical SVG. That's load-bearing for cache-key hashing in
PhoenixKitOG.Render.Cache.
Summary
Functions
Renders the canvas to an SVG string.
Render to a binary (the rasterizer pipes bytes via stdin). Convenience
over render/2 |> IO.iodata_to_binary/1.
Types
Functions
Renders the canvas to an SVG string.
context carries the variable values used to substitute bindings
({post.title} etc.) and the consumer module key used to look up
fallback example values.
Render to a binary (the rasterizer pipes bytes via stdin). Convenience
over render/2 |> IO.iodata_to_binary/1.