Mau.WhitespaceProcessor (mau v0.8.0)

View Source

Processes template AST to apply whitespace control based on trim options.

This module takes an AST with trim options and applies whitespace trimming logic to adjacent text nodes.

Summary

Functions

Applies whitespace control to an AST based on trim options.

Functions

apply_whitespace_control(nodes)

Applies whitespace control to an AST based on trim options.

Trims whitespace from adjacent text nodes when expressions or tags have trim_left or trim_right options set.

Examples

iex> nodes = [
...>   {:text, ["  before  "], []},
...>   {:expression, [{:variable, ["name"], []}], [trim_left: true]},
...>   {:text, ["  after  "], []}
...> ]
iex> Mau.WhitespaceProcessor.apply_whitespace_control(nodes)
[
  {:text, ["  before"], []},
  {:expression, [{:variable, ["name"], []}], [trim_left: true]},
  {:text, ["  after  "], []}
]