\Render\HTML Class
The \Render\HTML
class is the main class that is used to render HTML. It has special
methods for rendering HTML elements and wraps around \Render\Node
, \Render\XML
, and
\Render\Attribute
classes to essentially render HTML.
Properties
The \Render\HTML
class has the following properties:
$tag
- The tag name of the element. Ifnull
, then the element will not have a tag name.$id
- The id of the element. Ifnull
, then the element will not have an id.$classes
- The classes of the element, this can be a string, array, or aNode
orAttribute
object.$attributes
- The attributes of the element. This can be an array or anAttribute
object.$content
- The content of the element. This can be a string, aStream
object, or anotherRender\HTML
object.$styles
- The styles of the element. This is just a key-value array of styles.$prerender
- Whether or not to prerender the element. Iftrue
, then the element will be rendered when the object is constructed.$selfContained
- Whether or not the element is self-contained. Iftrue
, then the element will not have an end tag.
Methods
Constructor
The \Render\HTML
class can be initialized as follows:
Before and After Content
To set the before or after content of the element, use the $root->before
and $root->after
properties.
Stringable
The \Render\HTML
class implements the Stringable
interface, so it can be used as a string.
Hence, to render the HTML, just echo the object.
Render
However, to readably render the HTML, use the render
method.