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
bool | $transparent | ||
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.
Adds new element's child.
Creates and adds a new HtmlElement child.
Inserts child node.
Inserts (replaces) child node (ArrayAccess implementation).
Returns child node (ArrayAccess implementation).
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 101
__construct(string|null $name = null, array|string|null $attrs = null)
No description
at line 112
static HtmlElement
el(string|null $name = null, $attrs = null)
No description
at line 121
final HtmlElement
setName(string|null $name, bool|null $empty = null)
Changes element's name.
at line 134
final string|null
getName()
Returns element's name.
at line 143
final bool
isEmpty()
Is element empty?
at line 152
final void
__set(string $name, $value)
Overloaded setter for element's attribute.
at line 161
final
__get(string $name)
Overloaded getter for element's attribute.
at line 170
final HtmlElement
setAttribute(string $name, $value)
Sets element's attribute.
at line 181
final string|int|bool|string[]|null
getAttribute(string $name)
Returns element's attribute.
at line 190
final HtmlElement
href(string $path, array|null $query = null)
Special setter for element's attribute.
at line 207
final HtmlElement
setText(string $text)
Sets element's textual content.
at line 218
final string|null
getText()
Gets element's textual content.
at line 236
final HtmlElement
add(self|string $child)
Adds new element's child.
at line 245
final HtmlElement
create(string $name, array|string|null $attrs = null)
Creates and adds a new HtmlElement child.
at line 255
HtmlElement
insert(int|null $index, self|string $child, bool $replace = false)
Inserts child node.
at line 273
final void
offsetSet(int $index, HtmlElement $child)
Inserts (replaces) child node (ArrayAccess implementation).
at line 283
final mixed
offsetGet(int $index)
Returns child node (ArrayAccess implementation).
at line 293
final bool
offsetExists(int $index)
Exists child node? (ArrayAccess implementation).
at line 303
void
offsetUnset(int $index)
Removes child node (ArrayAccess implementation).
at line 314
final int
count()
Required by the Countable interface.
at line 323
void
removeChildren()
Removed all children.
at line 332
final ArrayIterator
getIterator()
Required by the IteratorAggregate interface.
at line 341
final array
getChildren()
Returns all of children.
at line 350
final string
toString(Texy $texy)
Renders element's start tag, content and end tag to internal string representation.
at line 377
final string
toHtml(Texy $texy)
Renders to final HTML.
at line 386
final string
toText(Texy $texy)
Renders to final text.
at line 395
string
startTag()
Returns element's start tag.
at line 445
string
endTag()
Returns element's end tag.
at line 458
__clone()
Clones all children too.
at line 468
final string
getContentType()
No description
at line 477
final void
validateAttrs(array $dtd)
No description
at line 494
bool
validateChild($child, array $dtd)
No description
at line 511
final LineParser
parseLine(Texy $texy, string $s)
Parses text as single line.
at line 522
final void
parseBlock(Texy $texy, string $s, bool $indented = false)
Parses text as block.
Traits
Better OOP experience.