Class Html
HTML helper.
$anchor = Html::el('a')->href($link)->setText('Nette'); $el->class = 'myclass'; echo $el; echo $el->startTag(), $el->endTag();
- Object
-
Html implements ArrayAccess, Countable, IteratorAggregate, Traversable
public static
Html
|
#
el(
string
$name = NULL,
array|string
$attrs = NULL
)
Static factory. Static factory. Parameters$name string element name (or NULL)$attrs array|string element's attributes (or textual content) |
final public
Html
|
#
setName(
string
$name,
bool
$isEmpty = NULL
)
Changes element's name. Changes element's name. Parameters$name string$isEmpty bool Is element empty?ReturnsHtml provides a fluent interface
Throws |
final public
string
|
#
getName(
)
Returns element's name. Returns element's name. |
final public
bool
|
#
isEmpty(
)
Is element empty? Is element empty? |
public
Html
|
#
addAttributes(
array
$attrs
)
Sets multiple attributes. Sets multiple attributes. Parameters$attrs arrayReturnsHtml provides a fluent interface
|
final public
void
|
#
__set(
string
$name,
mixed
$value
)
Overloaded setter for element's attribute. Overloaded setter for element's attribute. Parameters$name string HTML attribute name$value mixed HTML attribute value |
final public
mixed
&
|
#
__get(
string
$name
)
Overloaded getter for element's attribute. Overloaded getter for element's attribute. Parameters$name string HTML attribute nameReturnsmixed HTML attribute value
|
final public
void
|
#
__unset(
string
$name
)
Overloaded unsetter for element's attribute. Overloaded unsetter for element's attribute. Parameters$name string HTML attribute name |
final public
Html
|
#
__call(
string
$m,
array
$args
)
Overloaded setter for element's attribute. Overloaded setter for element's attribute. Parameters$m string HTML attribute name$args array (string) HTML attribute value or pair?ReturnsHtml provides a fluent interface
|
final public
Html
|
#
href(
string
$path,
array
$query = NULL
)
Special setter for element's attribute. Special setter for element's attribute. Parameters$path string path$query array queryReturnsHtml provides a fluent interface
|
final public
Html
|
#
setHtml(
string
$html
)
Sets element's HTML content. Sets element's HTML content. Parameters$html stringReturnsHtml provides a fluent interface
Throws |
final public
string
|
#
getHtml(
)
Returns element's HTML content. Returns element's HTML content. |
final public
Html
|
#
setText(
string
$text
)
Sets element's textual content. Sets element's textual content. Parameters$text stringReturnsHtml provides a fluent interface
Throws |
final public
string
|
#
getText(
)
Returns element's textual content. Returns element's textual content. |
final public
Html
|
#
add(
Html|string
$child
)
Adds new element's child. Adds new element's child. Parameters$child Html|string child nodeReturnsHtml provides a fluent interface
|
final public
Html
|
#
create(
string
$name,
array|string
$attrs = NULL
)
Creates and adds a new Html child. Creates and adds a new Html child. Parameters$name string elements's name$attrs array|string element's attributes (or textual content)ReturnsHtml created element
|
public
Html
|
#
insert(
int
$index,
Html
$child,
bool
$replace = false
)
Inserts child node. Inserts child node. Parameters$index int$child Html node$replace boolReturnsHtml provides a fluent interface
Throws |
final public
void
|
#
offsetSet(
int
$index,
Html
$child
)
Inserts (replaces) child node (ArrayAccess implementation). Inserts (replaces) child node (ArrayAccess implementation). Parameters$index int$child Html nodeImplementation of |
final public
mixed
|
#
offsetGet(
int
$index
)
Returns child node (ArrayAccess implementation). Returns child node (ArrayAccess implementation). Parameters$index int indexImplementation of |
final public
bool
|
#
offsetExists(
int
$index
)
Exists child node? (ArrayAccess implementation). Exists child node? (ArrayAccess implementation). Parameters$index int indexImplementation of |
public
void
|
#
offsetUnset(
int
$index
)
Removes child node (ArrayAccess implementation). Removes child node (ArrayAccess implementation). Parameters$index int indexImplementation of |
final public
int
|
#
count(
)
Required by the Countable interface. |
public
void
|
#
removeChildren(
)
Removed all children. Removed all children. |
final public
RecursiveIterator
|
#
getIterator(
bool
$deep = false
)
Iterates over a elements. Iterates over a elements. Parameters$deep bool recursive?Implementation of |
final public
|
#
getChildren(
)
Returns all of children. Returns all of children. return array |
final public
string
|
#
render(
int
$indent = NULL
)
Renders element's start tag, content and end tag. Renders element's start tag, content and end tag. Parameters$indent int indent |
final public
|
#
__toString(
)
|
final public
string
|
#
startTag(
)
Returns element's start tag. Returns element's start tag. |
final public
string
|
#
endTag(
)
Returns element's end tag. Returns element's end tag. |
final public
string
|
#
attributes(
)
Returns element's attributes. Returns element's attributes. |
public
|
#
__clone(
)
Clones all children too. Clones all children too. |
Methods Inherited From Object
getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
array
|
$attrs | array (
) |
element's attributes # |
protected
array
|
$children | array (
) |
of Html | string nodes # |
static
bool
|
$xhtml | true |
use XHTML syntax? # |
static
array
|
$emptyElements | array ( 'img' => 1, 'hr' => 1, 'br' => 1, 'input' => 1, 'meta' => 1, 'area' => 1, 'embed' => 1, 'keygen' => 1, 'source' => 1, 'base' => 1, 'col' => 1, 'link' => 1, 'param' => 1, 'basefont' => 1, 'frame' => 1, 'isindex' => 1, 'wbr' => 1, 'command' => 1, ) |
empty elements # |