HtmlRenderer
in package
implements
Renderer
uses
HtmlAttributeRenderer
FinalYes
Renders a node tree into an HTML5 string.
Supports compact (default) and pretty-printed output. Handles text escaping,
boolean attributes, void elements, and IDL-to-HTML name mapping
(e.g. className → class).
Table of Contents
Interfaces
- Renderer
- Renders a node tree into a complete string.
Properties
- $indentation : string|null
- $nameCache : array<class-string, array<string, string>>
- $nestedCache : array<NodeAttributes>, array<int, string>>
Methods
- __construct() : mixed
- render() : string
- isSingleTextChild() : bool
- renderAttributes() : string
- renderChildren() : string
- renderNode() : string
- renderObjectProperties() : array<int, string>
- resolveHtmlNames() : array<string, string>
- resolveNestedNames() : array<int, string>
Properties
$indentation read-only
private
string|null
$indentation
= null
$nameCache
private
array<class-string, array<string, string>>
$nameCache
= []
$nestedCache
private
array<NodeAttributes>, array<int, string>>
$nestedCache
= []
Methods
__construct()
public
__construct([string|null $indentation = null ]) : mixed
Parameters
- $indentation : string|null = null
-
Indentation string for pretty-print (e.g. ' ' or "\t"). Null for compact output.
render()
public
render(Node $node) : string
Parameters
- $node : Node
Return values
stringisSingleTextChild()
private
isSingleTextChild(array<int, Node> $childNodes) : bool
Parameters
- $childNodes : array<int, Node>
Return values
boolrenderAttributes()
private
renderAttributes(Node $node) : string
Parameters
- $node : Node
Return values
stringrenderChildren()
private
renderChildren(NodeCollection $children, int $depth) : string
Parameters
- $children : NodeCollection
- $depth : int
Return values
stringrenderNode()
private
renderNode(Node $node, int $depth) : string
Parameters
- $node : Node
- $depth : int
Return values
stringrenderObjectProperties()
private
renderObjectProperties(object $object) : array<int, string>
Parameters
- $object : object
Return values
array<int, string>resolveHtmlNames()
private
resolveHtmlNames(object $attributes) : array<string, string>
Parameters
- $attributes : object
Return values
array<string, string> —Map of IDL property name to HTML attribute name
resolveNestedNames()
private
resolveNestedNames(NodeAttributes $attributes) : array<int, string>
Parameters
- $attributes : NodeAttributes
Return values
array<int, string> —Property names marked with #[NestedAttributes]