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();
Properties
array | $attrs | ||
static bool | $xhtml | ||
static array | $emptyElements | ||
static array | $inlineElements | ||
static array | $optionalEnds | ||
static | $prohibits | ||
protected array | $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.
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).
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 82
__construct(string $name = null, array|string $attrs = null)
No description
at line 93
static HtmlElement
el(string $name = null, $attrs = null)
No description
at line 103
final HtmlElement
setName(string|null $name, bool $empty = null)
Changes element's name.
at line 118
final string|null
getName()
Returns element's name.
at line 127
final bool
isEmpty()
Is element empty?
at line 136
final void
__set(string $name, $value)
Overloaded setter for element's attribute.
at line 145
final
__get(string $name)
Overloaded getter for element's attribute.
at line 154
final HtmlElement
href(string $path, array $query = null)
Special setter for element's attribute.
at line 170
final HtmlElement
setText(string $text)
Sets element's textual content.
at line 185
final string|null
getText()
Gets element's textual content.
at line 202
final HtmlElement
add(HtmlElement|string $child)
Adds new element's child.
at line 212
final HtmlElement
create(string $name, array|string $attrs = null)
Creates and adds a new HtmlElement child.
at line 224
HtmlElement
insert(int|null $index, HtmlElement|string $child, bool $replace = false)
Inserts child node.
at line 247
final void
offsetSet(int $index, HtmlElement $child)
Inserts (replaces) child node (ArrayAccess implementation).
at line 258
final mixed
offsetGet(int $index)
Returns child node (ArrayAccess implementation).
at line 268
final bool
offsetExists(int $index)
Exists child node? (ArrayAccess implementation).
at line 278
void
offsetUnset(int $index)
Removes child node (ArrayAccess implementation).
at line 289
final int
count()
Required by the Countable interface.
at line 298
void
removeChildren()
Removed all children.
at line 307
final ArrayIterator
getIterator()
Required by the IteratorAggregate interface.
at line 316
final array
getChildren()
Returns all of children.
at line 325
final string
toString(Texy $texy)
Renders element's start tag, content and end tag to internal string representation.
at line 352
final string
toHtml(Texy $texy)
Renders to final HTML.
at line 361
final string
toText(Texy $texy)
Renders to final text.
at line 370
string
startTag()
Returns element's start tag.
at line 436
string
endTag()
Returns element's end tag.
at line 448
__clone()
Clones all children too.
at line 458
final string
getContentType()
No description
at line 468
final void
validateAttrs(array $dtd)
No description
at line 483
bool
validateChild($child, array $dtd)
No description
at line 499
final LineParser
parseLine(Texy $texy, string $s)
Parses text as single line.
at line 510
final void
parseBlock(Texy $texy, string $s, bool $indented = false)
Parses text as block.
Traits
Better OOP experience.