Html
class Html extends Object implements ArrayAccess, Countable, IteratorAggregate, IHtmlString
HTML helper.
$el = Html::el('a')->href($link)->setText('Nette');
$el->class = 'myclass';
echo $el;
echo $el->startTag(), $el->endTag();
Properties
array | $attrs | ||
protected array | $children | ||
static bool | $xhtml | ||
static array | $emptyElements |
Methods
Returns element's name.
Is element empty?
Sets multiple attributes.
Overloaded setter for element's attribute.
Overloaded getter for element's attribute.
Overloaded tester for element's attribute.
Overloaded unsetter for element's attribute.
Overloaded setter for element's attribute.
Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.
Returns element's HTML content.
Returns element's textual content.
Inserts (replaces) child node (\ArrayAccess implementation).
Exists child node? (\ArrayAccess implementation).
Removes child node (\ArrayAccess implementation).
Returns children count.
Removes all children.
Iterates over elements.
Returns all children.
Renders element's start tag, content and end tag.
No description
Returns element's start tag.
Returns element's end tag.
Returns element's attributes.
Clones all children too.
Details
at line 55
static Html
el($name = NULL, $attrs = NULL)
Static factory.
at line 85
Html
setName($name, $isEmpty = NULL)
Changes element's name.
at line 101
string
getName()
Returns element's name.
at line 111
bool
isEmpty()
Is element empty?
at line 122
Html
addAttributes(array $attrs)
Sets multiple attributes.
at line 135
void
__set($name, $value)
Overloaded setter for element's attribute.
at line 146
mixed
__get($name)
Overloaded getter for element's attribute.
at line 157
bool
__isset($name)
Overloaded tester for element's attribute.
at line 168
void
__unset($name)
Overloaded unsetter for element's attribute.
at line 180
mixed
__call($m, $args)
Overloaded setter for element's attribute.
at line 219
Html
href($path, $query = NULL)
Special setter for element's attribute.
at line 236
Html
data($name, $value = NULL)
Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.
at line 253
Html
setHtml($html)
Sets element's HTML content.
at line 268
string
getHtml()
Returns element's HTML content.
at line 288
Html
setText($text)
Sets element's textual content.
at line 301
string
getText()
Returns element's textual content.
at line 312
Html
add($child)
Adds new element's child.
at line 323
Html
addHtml($child)
Adds new element's child.
at line 334
Html
addText($text)
Appends plain-text string to element content.
at line 347
Html
create($name, $attrs = NULL)
Creates and adds a new Html child.
at line 362
Html
insert($index, $child, $replace = FALSE)
Inserts child node.
at line 386
void
offsetSet($index, $child)
Inserts (replaces) child node (\ArrayAccess implementation).
at line 397
Html|string
offsetGet($index)
Returns child node (\ArrayAccess implementation).
at line 408
bool
offsetExists($index)
Exists child node? (\ArrayAccess implementation).
at line 419
void
offsetUnset($index)
Removes child node (\ArrayAccess implementation).
at line 431
int
count()
Returns children count.
at line 441
void
removeChildren()
Removes all children.
at line 451
ArrayIterator
getIterator()
Iterates over elements.
at line 461
array
getChildren()
Returns all children.
at line 472
string
render($indent = NULL)
Renders element's start tag, content and end tag.
at line 500
string
__toString()
No description
at line 515
string
startTag()
Returns element's start tag.
at line 530
string
endTag()
Returns element's end tag.
at line 541
string
attributes()
internal |
Returns element's attributes.
at line 613
__clone()
Clones all children too.