Cherry.Theme.Renderer (cherry v0.6.1)

Copy Markdown View Source

Renders theme templates: runtime-evaluated, so themes work identically in project mode and binary mode (ADR 0002/0004). The file extension picks the language — .html.eex is classic EEx, .html.heex is HEEx with HTML-aware escaping, function components, and :for/:if.

HEEx templates render with Cherry.Theme.Helpers, Phoenix.Component, and Phoenix.HTML imported, plus every module the theme's optional components.exs defines — so <.card title={@title}> resolves the way a Phoenix developer expects.

Summary

Functions

Renders a named template through the lookup chain with the given assigns.

Renders a content template and wraps it in the theme's layout.

Functions

render(site, theme, name, assigns)

@spec render(Cherry.Site.t(), Cherry.Theme.t(), atom(), keyword()) ::
  {:ok, String.t()} | {:error, String.t()}

Renders a named template through the lookup chain with the given assigns.

render_in_layout(context, name, assigns)

@spec render_in_layout(Cherry.Theme.RenderContext.t(), atom(), keyword()) ::
  {:ok, String.t()} | {:error, String.t()}

Renders a content template and wraps it in the theme's layout.

The context carries the layout's own assigns: page title, the framework-owned SEO head block (Cherry.SEO.Head, interpolated verbatim inside <head>), and the navigation.