Surface.Formatter.Phase behaviour (SurfaceFormatter v0.7.5) View Source
A phase implementing a single "rule" for formatting code. These work as middleware
between Surface.Compiler.Parser.parse
and Surface.Formatter.Render.node/2
to modify node lists before they are rendered.
Some phases rely on other phases; @moduledoc
s should make this explicit.
For reference, the formatter operates by running these phases in the following order:
Link to this section Summary
Types
A node that takes a list of nodes and returns them back after applying a transformation
A list of nodes
Functions
Given a list of nodes, find all "element" nodes (HTML elements or Surface components) and transform children of those nodes using the given function.
Given a list of nodes, find all "element" nodes (HTML elements or Surface components) and transform children of those nodes using the given function.
Callbacks
The function implementing the phase. Returns the given nodes with the transformation applied.
Link to this section Types
Specs
A node that takes a list of nodes and returns them back after applying a transformation
Specs
nodes() :: [Surface.Formatter.formatter_node()]
A list of nodes
Link to this section Functions
Specs
transform_element_children(nodes(), node_transformer()) :: nodes()
Given a list of nodes, find all "element" nodes (HTML elements or Surface components) and transform children of those nodes using the given function.
Useful for recursing deeply through the entire tree of nodes.
Given a list of nodes, find all "element" nodes (HTML elements or Surface components) and transform children of those nodes using the given function.
Recurses deeply through the tree, unlike transform_element_children
, which only affects
a single layer.
Link to this section Callbacks
Specs
run( nodes :: [Surface.Formatter.formatter_node()], opts :: [Surface.Formatter.option()] ) :: [Surface.Formatter.formatter_node()]
The function implementing the phase. Returns the given nodes with the transformation applied.