HtmlElement
class HtmlElement implements ArrayAccess, IteratorAggregate
HTML helper.
usage: $anchor = (new HtmlElement('a'))->href($link)->setText('Texy'); $el->class = 'myclass';
echo $el->startTag(), $el->endTag();
Constants
InnerText |
|
InnerTransparent |
|
Properties
array<string,string|int|bool|string[]|null> | $attrs | ||
static array<string,int> | $emptyElements | ||
static array<string,int> | $inlineElements | ||
static array<string,int> | $optionalEnds | ||
static array<string,array<int,string>> | $prohibits | ||
protected HtmlElement|string> | $children |
Methods
No description
No description
Changes element's name.
Returns element's name.
Is element empty?
Overloaded setter for element's attribute.
Overloaded getter for element's attribute.
Sets element's attribute.
Returns element's attribute.
Special setter for element's attribute.
Sets element's textual content.
Gets element's textual content.
Creates and adds a new HtmlElement child.
Inserts (replaces) child node (ArrayAccess implementation).
No description
Exists child node? (ArrayAccess implementation).
Removes child node (ArrayAccess implementation).
Required by the Countable interface.
Removed all children.
Required by the IteratorAggregate interface.
Returns all of children.
Returns element's start tag.
Returns element's end tag.
Clones all children too.
No description
No description
No description
Details
at line 99
__construct(string|null $name = null, array|string $attrs = null)
No description
at line 110
static HtmlElement
el(string|null $name = null, $attrs = null)
No description
at line 119
final HtmlElement
setName(string|null $name, bool|null $empty = null)
Changes element's name.
at line 132
final string|null
getName()
Returns element's name.
at line 141
final bool
isEmpty()
Is element empty?
at line 150
final void
__set(string $name, $value)
Overloaded setter for element's attribute.
at line 159
final
__get(string $name)
Overloaded getter for element's attribute.
at line 168
final HtmlElement
setAttribute(string $name, $value)
Sets element's attribute.
at line 179
final string|int|bool|string[]|null
getAttribute(string $name)
Returns element's attribute.
at line 188
final HtmlElement
href(string $path, array|null $query = null)
Special setter for element's attribute.
at line 205
final HtmlElement
setText(string $text)
Sets element's textual content.
at line 216
final string|null
getText()
Gets element's textual content.
at line 235
final HtmlElement
add(HtmlElement|string $child)
Adds new element's child.
at line 245
final HtmlElement
create(string $name, array|string $attrs = null)
Creates and adds a new HtmlElement child.
at line 257
HtmlElement
insert(int|null $index, HtmlElement|string $child, bool $replace = false)
Inserts child node.
at line 279
final void
offsetSet(int $index, HtmlElement $child)
Inserts (replaces) child node (ArrayAccess implementation).
at line 285
final
offsetGet($index)
No description
at line 301
final bool
offsetExists(int $index)
Exists child node? (ArrayAccess implementation).
at line 311
void
offsetUnset(int $index)
Removes child node (ArrayAccess implementation).
at line 322
final int
count()
Required by the Countable interface.
at line 331
void
removeChildren()
Removed all children.
at line 340
final ArrayIterator
getIterator()
Required by the IteratorAggregate interface.
at line 349
final array
getChildren()
Returns all of children.
at line 358
final string
toString(Texy $texy)
Renders element's start tag, content and end tag to internal string representation.
at line 385
final string
toHtml(Texy $texy)
Renders to final HTML.
at line 394
final string
toText(Texy $texy)
Renders to final text.
at line 403
string
startTag()
Returns element's start tag.
at line 453
string
endTag()
Returns element's end tag.
at line 466
__clone()
Clones all children too.
at line 476
final string
getContentType()
No description
at line 485
final void
validateAttrs(array $dtd)
No description
at line 502
bool
validateChild($child, array $dtd)
No description
at line 519
final LineParser
parseLine(Texy $texy, string $s)
Parses text as single line.
at line 530
final void
parseBlock(Texy $texy, string $s, bool $indented = false)
Parses text as block.
Traits
Better OOP experience.