MishkaGervaz.Form.Web.Renderer (MishkaGervaz v0.0.2)

Copy Markdown View Source

Bridge between LiveComponent and Form Templates.

This module is a thin orchestrator that:

  • Selects the appropriate template based on state
  • Prepares minimal assigns for the template
  • Delegates rendering to the template

Architecture

LiveComponent → Renderer (bridge) → Template → UIAdapter (components)

Performance Optimization

Renderer passes two key assigns to templates:

  • @static - Same reference always, LiveView skips re-render (O(1) comparison)
  • @state - Changes trigger re-render only for parts using dynamic fields

See MishkaGervaz.Form.Web.Live (the LiveComponent that delegates to render/1), MishkaGervaz.Form.Web.State (struct shape — :static / :template / etc.), MishkaGervaz.Form.Behaviours.Template, and the default template MishkaGervaz.Form.Templates.Standard.

Summary

Functions

Renders the form through the template the resource declared.

Functions

render(assigns)

@spec render(map()) :: Phoenix.LiveView.Rendered.t()

Renders the form through the template the resource declared.

Called by MishkaGervaz.Form.Web.Live. Splits the state into @static and @state before handing over, so LiveView can skip the half that never changes, and falls back to the template's loading state until the form has been built.