Athanor.Renderer (Athanor v0.1.0-beta.1)

Copy Markdown View Source

Unified render dispatch over an Athanor.Tree.

Iterates tree["content"]. For each node:

  1. Resolves the component module via Athanor.Registry.lookup/1.
  2. If the module exports render/3 (new Athanor.Component path), calls module.render(:live, node, ctx).
  3. Otherwise dispatches via the configured :legacy_adapter — see Application.put_env(:athanor, :legacy_adapter, {Mod, :fun}). The adapter receives (component_module, assigns) and returns renderable HEEx, which is embedded inline.
  4. For legacy modules implementing has_required_props?/1, the node is SKIPPED entirely (no output) when edit_mode=false and required props are missing — matching the storefront's pre-Athanor behaviour.
  5. If the type cannot be resolved at all, renders an inline developer placeholder. Does NOT crash the parent LiveView.

Both editor-canvas and storefront-page call sites converge here, so a per-component cutover only needs to change the component module — the dispatch logic is shared.

Summary

Functions

Render a single node. Named node_component to avoid colliding with Kernel.node/1.

Render every root node in the tree.

Functions

node_component(assigns)

Render a single node. Named node_component to avoid colliding with Kernel.node/1.

Attributes

  • node (:map) (required)
  • ctx (Athanor.Ctx) (required)
  • edit_mode (:boolean) - Defaults to false.
  • show_config (:boolean) - Defaults to false.
  • selected_component_id (:string) - Defaults to nil.

tree(assigns)

Render every root node in the tree.

Output mirrors the pre-Athanor storefront renderer layout: a single flex flex-col gap-4 wrapper, with each node's rendered output directly inside (no per-node wrapping div).

Attributes

  • tree (:map) (required) - An Athanor.Tree-shaped map: %{"content" => [...]}.
  • ctx (Athanor.Ctx) (required)
  • edit_mode (:boolean) - Defaults to false.
  • show_config (:boolean) - Defaults to false.
  • selected_component_id (:string) - Defaults to nil.