AttrEngine.Render.Attr (attr_engine v0.3.0)

Copy Markdown View Source

Renders individual attributes to HTML based on type and ui_config.

Pure functions — no DB calls, no side effects. Pattern-matched on type atom.

Supported types

  • :string — text wrapped in tag (default: span)
  • :select — same as string (value already resolved)
  • :number / :integer — number as text in tag
  • :boolean — renders tag when true, empty when false
  • :text — longer content as raw HTML in tag (default: div)
  • :asset — renders as <img> tag from asset map or URL
  • :editorjs — delegates to EditorJS/Lexical renderer (via callback)
  • :json — not directly renderable, returns empty

ui_config keys

  • "tag" — HTML tag to wrap in (default varies by type)
  • "classes" — CSS classes
  • "custom_style" — inline style string

Extension

Host apps can register custom type renderers:

config :attr_engine, custom_renderers: %{
  sequence: MyApp.SequenceRenderer
}

Custom renderers must implement render(ui_config, value) :: String.t().

Summary

Functions

html(type, ui_config, value)