Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

Exceptions

  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage

Class Html

HTML helper.

$el = Html::el('a')->href($link)->setText('Nette');
$el->class = 'myclass';
echo $el;

echo $el->startTag(), $el->endTag();
Object
Extended by Html implements ArrayAccess, Countable, IteratorAggregate
Package: Nette\Utils
Author: David Grudl
Located at Utils/Html.php
Methods summary
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 plain text content

Returns

Html
public Html
# setName( string $name, boolean $isEmpty = NULL )

Changes element's name.

Changes element's name.

Parameters

$name
string
$isEmpty
boolean
Is element empty?

Returns

Html

Throws

InvalidArgumentException
public string
# getName( )

Returns element's name.

Returns element's name.

Returns

string
public boolean
# isEmpty( )

Is element empty?

Is element empty?

Returns

boolean
public Html
# addAttributes( array $attrs )

Sets multiple attributes.

Sets multiple attributes.

Parameters

$attrs
array

Returns

Html
public
# __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

Throws

MemberAccessException
if the property is not defined or is read-only

Overrides

Object::__set()
public mixed &
# __get( string $name )

Overloaded getter for element's attribute.

Overloaded getter for element's attribute.

Parameters

$name
string
HTML attribute name

Returns

mixed
HTML attribute value

Throws

MemberAccessException
if the property is not defined.

Overrides

Object::__get()
public boolean
# __isset( string $name )

Overloaded tester for element's attribute.

Overloaded tester for element's attribute.

Parameters

$name
string
HTML attribute name

Returns

boolean

Overrides

Object::__isset()
public
# __unset( string $name )

Overloaded unsetter for element's attribute.

Overloaded unsetter for element's attribute.

Parameters

$name
string
HTML attribute name

Throws

MemberAccessException

Overrides

Object::__unset()
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?

Returns

Html

Throws

MemberAccessException

Overrides

Object::__call()
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
query

Returns

Html
public Html
# setHtml( string $html )

Sets element's HTML content.

Sets element's HTML content.

Parameters

$html
string
raw HTML string

Returns

Html

Throws

InvalidArgumentException
public string
# getHtml( )

Returns element's HTML content.

Returns element's HTML content.

Returns

string
public Html
# setText( string $text )

Sets element's textual content.

Sets element's textual content.

Parameters

$text
string

Returns

Html

Throws

InvalidArgumentException
public string
# getText( )

Returns element's textual content.

Returns element's textual content.

Returns

string
public Html
# add( Html|string $child )

Adds new element's child.

Adds new element's child.

Parameters

$child
Html|string
Html node or raw HTML string

Returns

Html
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 raw HTML string

Returns

Html
created element
public Html
# insert( integer|null $index, Html|string $child, boolean $replace = FALSE )

Inserts child node.

Inserts child node.

Parameters

$index
integer|null
position of NULL for appending
$child
Html|string
Html node or raw HTML string
$replace
boolean

Returns

Html

Throws

InvalidArgumentException
public
# offsetSet( integer|null $index, Html|string $child )

Inserts (replaces) child node (ArrayAccess implementation).

Inserts (replaces) child node (ArrayAccess implementation).

Parameters

$index
integer|null
position of NULL for appending
$child
Html|string
Html node or raw HTML string

Implementation of

ArrayAccess::offsetSet()
public Html|string
# offsetGet( integer $index )

Returns child node (ArrayAccess implementation).

Returns child node (ArrayAccess implementation).

Parameters

$index
integer

Returns

Html|string

Implementation of

ArrayAccess::offsetGet()
public boolean
# offsetExists( integer $index )

Exists child node? (ArrayAccess implementation).

Exists child node? (ArrayAccess implementation).

Parameters

$index
integer

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public
# offsetUnset( integer $index )

Removes child node (ArrayAccess implementation).

Removes child node (ArrayAccess implementation).

Parameters

$index
integer

Implementation of

ArrayAccess::offsetUnset()
public integer
# count( )

Returns children count.

Returns children count.

Returns

integer

Implementation of

Countable::count()
public
# removeChildren( )

Removed all children.

Removed all children.

public RecursiveIterator
# getIterator( boolean $deep = FALSE )

Iterates over a elements.

Iterates over a elements.

Parameters

$deep
boolean
recursive?

Returns

RecursiveIterator

Implementation of

IteratorAggregate::getIterator()
public array
# getChildren( )

Returns all of children.

Returns all of children.

Returns

array
public string
# render( integer $indent = NULL )

Renders element's start tag, content and end tag.

Renders element's start tag, content and end tag.

Parameters

$indent
integer

Returns

string
public
# __toString( )
public string
# startTag( )

Returns element's start tag.

Returns element's start tag.

Returns

string
public string
# endTag( )

Returns element's end tag.

Returns element's end tag.

Returns

string
public
# __clone( )

Clones all children too.

Clones all children too.

Methods inherited from Object
__callStatic(), extensionMethod(), getReflection()
Properties summary
public array $attrs array()
#

element's attributes

element's attributes

protected array $children array()
#

of Html | string nodes

of Html | string nodes

public static boolean $xhtml TRUE
#

use XHTML syntax?

use XHTML syntax?

public 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,'track'=>1)
#

empty (void) elements

empty (void) elements

Magic properties inherited from Object
$reflection
Nette Framework 2.0.18 (for PHP 5.2, un-prefixed) API documentation generated by ApiGen 2.8.0