Resolves dynamic values in A2UI component props.
Values can be:
- Literals — returned as-is
- Path bindings (
%{"path" => "/some/path"}) — resolved from the data model - Function calls (
%{"call" => "formatNumber", ...}) — known functions evaluated server-side, unknown ones (e.g.,openUrl, validators) returned as-is
Summary
Functions
Resolves a value against the data model.
Functions
@spec resolve(any(), A2UI.DataModel.t(), String.t() | nil) :: {:ok, any()} | :error
Resolves a value against the data model.
Parameters
value— the raw prop value (literal, path binding, or function call)data_model— the%DataModel{}to resolve paths againstscope_path— base path for relative path resolution (used in templates)
Examples
iex> dm = A2UI.DataModel.new(%{"user" => %{"name" => "Alice"}})
iex> A2UI.DataModel.Binding.resolve(%{"path" => "/user/name"}, dm)
{:ok, "Alice"}
iex> A2UI.DataModel.Binding.resolve("hello", A2UI.DataModel.new())
{:ok, "hello"}