Lavash.Optimistic.ClientBindingsTransformer (Lavash v0.4.0-rc.5)

Copy Markdown View Source

Layer-4 token transformer: handles <.lavash_component> invocations, propagating client-side binding metadata to child components.

Two things happen on every <.lavash_component> call:

  1. Inherit parent bindings. Inside a component context (the caller is itself a Lavash.Component), inject __lavash_client_bindings__={@__lavash_client_bindings__} so the child sees the same binding map the parent has.

  2. Expand bind={[child: :parent]} shorthand. For each {child, parent} pair, add child={@parent} to the component's attrs so the parent's field value is passed down as the child's prop.

Skipped when metadata[:layer] == :base. Other tag attrs and body_expr nodes are untouched — this transformer only cares about component nodes.