Lavash.Optimistic.Transformers.AnalyzeOptimisticTemplate (Lavash v0.4.0-rc.4)

Copy Markdown View Source

Layer-4 template analysis: extracts the derives that drive client-side optimistic updates.

Originally bundled into the layer-1 Lavash.Component.Transformers.AnalyzeTemplate, then split out per docs/ARCHITECTURE.md punchlist item #4. This transformer has zero responsibility for layer-1 validation collection (which stays in AnalyzeTemplate) — it only walks the already-parsed template tree looking for optimistic-update opportunities and emits the JS-side metadata the colocated-JS extractor will consume.

Outputs

  • :lavash_attr_derives — list of attr-derive specs (disabled={...}, class={...}, hidden={...} over optimistic-only deps) that the JS hook will re-evaluate client-side when a dep changes.

  • :lavash_subtree_derives — list of subtree-derive specs (:if/:for blocks over optimistic state) that the JS hook will re-render with morphdom-style patching.

  • Updated :lavash_template_tokens — the parser tree with data-lavash-html attributes injected onto subtree-derive parent nodes so the JS hook can locate them at runtime.

Ordering

Runs after AnalyzeTemplate (so the layer-1 validation data is already collected; we read the same :lavash_template_tokens) and before ExtractColocatedJs (which consumes our outputs to emit JS).

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.