Lavash.Template.PhxTargetTransformer (Lavash v0.4.0-rc.5)

Copy Markdown View Source

Layer-1 token transformer: auto-injects phx-target={@myself} on any tag inside a Lavash.Component that carries a phx-* event attribute (phx-click, phx-submit, etc.).

Without this injection, a phx-click="bump" button inside a component would send the event to the parent LiveView, not the component — almost never what the author meant. The injection is a quality-of-life DSL behavior, not optimism-related; it belongs with layer 1 (the base DSL plumbing).

Only fires when metadata[:context] == :component, so plain LiveView templates pass through unchanged.