PhoenixKitOG.Render (PhoenixKitOG v0.1.0)

Copy Markdown View Source

Top-level rendering facade. Given a template + binding values, produces a PNG (cached) and returns its public URL.

Pipeline:

template + context    cache lookup
                        
                         hit   served path
                        
                         miss  SVG generation
                                     rasterize (rsvg-convert)
                                     atomic write to cache
                                     served path

When the rasterizer isn't installed (:rasterizer_missing), the caller (PhoenixKitOG.refine_og/4) is expected to drop back to the pre-existing og.image — never a crash.

Summary

Functions

Returns just the public URL for a key (whether or not it exists).

Returns {:ok, public_url} on success, {:error, reason} on failure. Side effect: caches the PNG on disk so the next call is a no-op.

Functions

cache_url(key)

@spec cache_url(String.t()) :: String.t()

Returns just the public URL for a key (whether or not it exists).

render_url(template, context)

@spec render_url(PhoenixKitOG.Schemas.Template.t(), map()) ::
  {:ok, String.t()} | {:error, term()}

Returns {:ok, public_url} on success, {:error, reason} on failure. Side effect: caches the PNG on disk so the next call is a no-op.