Lavash.Template (Lavash v0.3.0-rc.0)

Copy Markdown View Source

Utilities for parsing HEEx templates into tree structures.

Provides tokenize/1 and parse/1 for converting HEEx source into a tree of nodes that can be analyzed for subtree derive extraction and other compile-time transformations.

Summary

Functions

Parses tokens into a tree structure.

Tokenizes HEEx source into a list of tokens.

Functions

parse(tokens)

Parses tokens into a tree structure.

Each node is:

  • {:element, tag, attrs, children, meta} for HTML elements
  • {:text, content} for text nodes
  • {:expr, code, meta} for Elixir expressions

tokenize(source, opts \\ [])

Tokenizes HEEx source into a list of tokens.

Options:

  • :line - starting line number (default 1)
  • :file - source file path for error messages (default "nofile")
  • :indentation - indentation level (default 0)