Volt.CSS.AST (Volt v0.13.1)

Copy Markdown View Source

Helpers for parser-backed CSS AST transforms.

Centralizes the Vize parse → mutate → print flow so CSS transforms handle parse and print failures consistently.

Summary

Functions

Walk CSS URL nodes without accumulator state.

Walk CSS URL nodes with accumulator state.

Parse CSS, apply an AST transform, and print the result.

Types

transform_result()

@type transform_result() ::
  {:ok, %{code: String.t(), metadata: term()}} | {:error, term()}

Functions

postwalk_urls(ast, fun)

@spec postwalk_urls(term(), (String.t(), map() -> map())) :: term()

Walk CSS URL nodes without accumulator state.

postwalk_urls(ast, acc, fun)

@spec postwalk_urls(term(), term(), (String.t(), map(), term() -> {map(), term()})) ::
  {term(), term()}

Walk CSS URL nodes with accumulator state.

transform(css, filename, transform_fn)

@spec transform(String.t(), String.t() | nil, (term() -> {term(), term()})) ::
  transform_result()

Parse CSS, apply an AST transform, and print the result.