Namespaces

  • Nette
    • Application
    • Caching
    • Collections
    • Config
    • Forms
    • IO
    • Loaders
    • Mail
    • Reflection
    • Security
    • Templates
    • Web
  • None
  • PHP

Classes

  • Ftp
  • Html
  • HttpContext
  • HttpRequest
  • HttpResponse
  • HttpUploadedFile
  • Session
  • SessionNamespace
  • Uri
  • UriScript
  • User

Interfaces

  • IHttpRequest
  • IHttpResponse
  • IUser

Exceptions

  • FtpException
  • Overview
  • Namespace
  • Class
  • Tree
  • Other releases

Class Html

HTML helper.

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

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

Returns

Nette\Web\Html
final public Nette\Web\Html
# setName( string $name, boolean $isEmpty = NULL )

Changes element's name.

Changes element's name.

Parameters

$name
string
$isEmpty
boolean
Is element empty?

Returns

Nette\Web\Html
provides a fluent interface

Throws

InvalidArgumentException
final public string
# getName( )

Returns element's name.

Returns element's name.

Returns

string
final public boolean
# isEmpty( )

Is element empty?

Is element empty?

Returns

boolean
final 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
final 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.
final public
# __unset( string $name )

Overloaded unsetter for element's attribute.

Overloaded unsetter for element's attribute.

Parameters

$name
string
HTML attribute name

Throws

MemberAccessException
final public Nette\Web\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

Nette\Web\Html
provides a fluent interface

Throws

MemberAccessException
final public Nette\Web\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

Nette\Web\Html
provides a fluent interface
final public Nette\Web\Html
# setHtml( string $html )

Sets element's HTML content.

Sets element's HTML content.

Parameters

$html
string

Returns

Nette\Web\Html
provides a fluent interface

Throws

InvalidArgumentException
final public string
# getHtml( )

Returns element's HTML content.

Returns element's HTML content.

Returns

string
final public Nette\Web\Html
# setText( string $text )

Sets element's textual content.

Sets element's textual content.

Parameters

$text
string

Returns

Nette\Web\Html
provides a fluent interface

Throws

InvalidArgumentException
final public string
# getText( )

Returns element's textual content.

Returns element's textual content.

Returns

string
final public Nette\Web\Html
# add( Nette\Web\Html|string $child )

Adds new element's child.

Adds new element's child.

Parameters

$child
Nette\Web\Html|string
child node

Returns

Nette\Web\Html
provides a fluent interface
final public Nette\Web\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)

Returns

Nette\Web\Html
created element
public Nette\Web\Html
# insert( integer $index, Nette\Web\Html $child, boolean $replace = FALSE )

Inserts child node.

Inserts child node.

Parameters

$index
integer
$child
Nette\Web\Html
node
$replace
boolean

Returns

Nette\Web\Html
provides a fluent interface

Throws

Exception
final public
# offsetSet( integer $index, Nette\Web\Html $child )

Inserts (replaces) child node (\ArrayAccess implementation).

Inserts (replaces) child node (\ArrayAccess implementation).

Parameters

$index
integer
$child
Nette\Web\Html
node

Implementation of

ArrayAccess::offsetSet
final public mixed
# offsetGet( integer $index )

Returns child node (\ArrayAccess implementation).

Returns child node (\ArrayAccess implementation).

Parameters

$index
integer
index

Returns

mixed

Implementation of

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

Exists child node? (\ArrayAccess implementation).

Exists child node? (\ArrayAccess implementation).

Parameters

$index
integer
index

Returns

boolean

Implementation of

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

Removes child node (\ArrayAccess implementation).

Removes child node (\ArrayAccess implementation).

Parameters

$index
integer
index

Implementation of

ArrayAccess::offsetUnset
final public integer
# count( )

Required by the \Countable interface.

Required by the \Countable interface.

Returns

integer

Implementation of

Countable::count
public
# removeChildren( )

Removed all children.

Removed all children.

final public RecursiveIterator
# getIterator( boolean $deep = FALSE )

Iterates over a elements.

Iterates over a elements.

Parameters

$deep
boolean
recursive?

Returns

RecursiveIterator

Implementation of

IteratorAggregate::getIterator
final public
# getChildren( )

Returns all of children. return array

Returns all of children. return array

final 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
indent

Returns

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

Returns element's start tag.

Returns element's start tag.

Returns

string
final public string
# endTag( )

Returns element's end tag.

Returns element's end tag.

Returns

string
final public string
# attributes( )

Returns element's attributes.

Returns element's attributes.

Returns

string
public
# __clone( )

Clones all children too.

Clones all children too.

Methods inherited from Nette\Object
__callStatic(), __isset(), 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,'command'=>1,'keygen'=>1,'source'=>1, 'base'=>1,'col'=>1,'link'=>1,'param'=>1,'basefont'=>1,'frame'=>1,'isindex'=>1,'wbr'=>1,'embed'=>1)
#

empty elements

empty elements

Nette Framework 0.9.7 API documentation generated by ApiGen 2.3.0