Lavash.Component.Transformers.AnalyzeTemplate (Lavash v0.4.0-rc.5)

Copy Markdown View Source

Layer-1 template analysis: collects compile-time validation data from the already-parsed template tree.

Reads :lavash_template_tokens (the parser tree produced by TokenizeTemplate) and walks it to extract:

  • :lavash_template_phx_events — every phx-click, phx-submit, phx-mouseenter, etc. occurrence (with static-string event names) grouped per node alongside the same node's phx-value-* attribute keys. ValidateTemplate cross-checks each event name against declared actions and each phx-value key against the actions' params.

  • :lavash_template_assign_refs — every @name reference anywhere an Elixir expression appears in HEEx (inline {@x}, attr class={@x}, <%= @x %>, :if={@x}, etc.). ValidateTemplate checks each against the declared state / props / slots / calculations / etc.

What this transformer does NOT do

Layer-4 (optimism) work — extracting subtree derives, attr derives, and injecting data-lavash-html attrs — lives in Lavash.Optimistic.Transformers.AnalyzeOptimisticTemplate, which runs after this transformer. Per docs/ARCHITECTURE.md punchlist item #4, the two were split so layer-1 consumers don't pay for layer-4 analysis.

Summary

Functions

after?(arg1)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(arg1)

Callback implementation for Spark.Dsl.Transformer.before?/1.

transform(dsl_state)

Callback implementation for Spark.Dsl.Transformer.transform/1.