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
  • PHP

Classes

  • Arrays
  • Finder
  • Html
  • Json
  • LimitedScope
  • MimeTypeDetector
  • Neon
  • NeonEntity
  • Paginator
  • Strings
  • Tokenizer
  • Validators

Exceptions

  • AssertionException
  • JsonException
  • NeonException
  • RegexpException
  • Overview
  • Package
  • Class
  • Tree

Class Html

HTML helper.

$anchor = 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 textual content)

Returns

Html
final 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
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
public Html
# addAttributes( array $attrs )

Sets multiple attributes.

Sets multiple attributes.

Parameters

$attrs
array

Returns

Html
provides a fluent interface
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

Overrides

Object::__set
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.

Overrides

Object::__get
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

Overrides

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

Returns

Html
provides a fluent interface

Throws

MemberAccessException

Overrides

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

Returns

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

Sets element's HTML content.

Sets element's HTML content.

Parameters

$html
string

Returns

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 Html
# setText( string $text )

Sets element's textual content.

Sets element's textual content.

Parameters

$text
string

Returns

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 Html
# add( Html|string $child )

Adds new element's child.

Adds new element's child.

Parameters

$child
Html|string
child node

Returns

Html
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)

Returns

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

Inserts child node.

Inserts child node.

Parameters

$index
integer
$child
Html
node
$replace
boolean

Returns

Html
provides a fluent interface

Throws

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

Inserts (replaces) child node (ArrayAccess implementation).

Inserts (replaces) child node (ArrayAccess implementation).

Parameters

$index
integer
$child
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 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,'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

empty elements

Nette Framework 2.0.0 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0