AttrEngine.Render.Block (attr_engine v0.3.0)

Copy Markdown View Source

Renders a complete block from its type, data, and locale.

Composes the 4-layer cascade, resolves locale, renders each attribute via AttrEngine.Render.Attr, and wraps in a container.

Rendering modes

  • HTML (default) — renders to HTML string via Attr.html/3
  • Envelope — returns a structured map for JS/animation layers

Host apps can override rendering by registering component modules:

config :attr_engine, component_blocks: %{
  "superhero" => MyApp.Components.Superhero,
  "piece" => ArtistCircle.PieceRenderer
}

Component modules must implement render(data, locale) :: String.t().

Block type aliases

Handles normalization of common aliases:

"image" => "image_block"
"heading-block" => "heading_block"

Summary

Functions

Returns true if the handle is a registered component block.

Renders a block by its type handle.

Functions

component_block?(handle)

Returns true if the handle is a registered component block.

render(block_type_handle, data, locale, opts \\ [])

@spec render(String.t(), map(), String.t(), keyword()) :: String.t() | map()

Renders a block by its type handle.

Resolves the block type from DB, loads attribute metadata via the cascade, resolves locale on the data, and composes HTML.

Options

  • :asd_ui_config — per-instance ui_config overrides (layer 3)
  • :mode:html (default) or :envelope
  • :prefix — Postgres schema prefix for multi-tenant query scoping