Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • ArrayHash
  • ArrayList
  • Arrays
  • Callback
  • DateTime
  • FileSystem
  • Finder
  • Html
  • Image
  • Json
  • LimitedScope
  • MimeTypeDetector
  • ObjectMixin
  • Paginator
  • Random
  • Strings
  • TokenIterator
  • Tokenizer
  • Validators

Interfaces

  • IHtmlString

Exceptions

  • AssertionException
  • ImageException
  • JsonException
  • RegexpException
  • TokenizerException
  • UnknownImageFileException
  • Overview
  • Namespace
  • 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();
Nette\Object
Extended by Nette\Utils\Html implements ArrayAccess, Countable, IteratorAggregate, Nette\Utils\IHtmlString
Namespace: Nette\Utils
Located at Utils/Html.php
Methods summary
public static Nette\Utils\Html
# el( string $name = NULL, array|string $attrs = NULL )

Static factory.

Static factory.

Parameters

$name
name (or NULL)
$attrs
attributes or plain text content

Returns

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

Changes element's name.

Changes element's name.

Parameters

$name
$isEmpty
element empty?

Returns

Nette\Utils\Html
static

Throws

Nette\InvalidArgumentException
Nette\InvalidArgumentException
public string
# getName( )

Returns element's name.

Returns element's name.

Returns

string
string
public boolean
# isEmpty( )

Is element empty?

Is element empty?

Returns

boolean
bool
public Nette\Utils\Html
# addAttributes( array $attrs )

Sets multiple attributes.

Sets multiple attributes.

Parameters

$attrs

Returns

Nette\Utils\Html
static
public
# __set( string $name, mixed $value )

Overloaded setter for element's attribute.

Overloaded setter for element's attribute.

Parameters

$name
attribute name
$value
attribute value

Throws

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

Overrides

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

Overloaded getter for element's attribute.

Overloaded getter for element's attribute.

Parameters

$name
attribute name

Returns

mixed
HTML attribute value

Throws

MemberAccessException
if the property is not defined.

Overrides

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

Overloaded tester for element's attribute.

Overloaded tester for element's attribute.

Parameters

$name
attribute name

Returns

boolean
bool

Overrides

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

Overloaded unsetter for element's attribute.

Overloaded unsetter for element's attribute.

Parameters

$name
attribute name

Throws

MemberAccessException
MemberAccessException

Overrides

Nette\Object::__unset()
public Nette\Utils\Html
# __call( string $m, array $args )

Overloaded setter for element's attribute.

Overloaded setter for element's attribute.

Parameters

$m
attribute name
$args
HTML attribute value or pair?

Returns

Nette\Utils\Html
static

Throws

MemberAccessException
MemberAccessException

Overrides

Nette\Object::__call()
public Nette\Utils\Html
# href( string $path, array $query = NULL )

Special setter for element's attribute.

Special setter for element's attribute.

Parameters

$path
path
$query
query

Returns

Nette\Utils\Html
static
public Nette\Utils\Html
# data( $name, $value = NULL )

Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.

Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.

Returns

Nette\Utils\Html
static
public Nette\Utils\Html
# setHtml( string $html )

Sets element's HTML content.

Sets element's HTML content.

Parameters

$html
HTML string

Returns

Nette\Utils\Html
static

Throws

Nette\InvalidArgumentException
Nette\InvalidArgumentException
public string
# getHtml( )

Returns element's HTML content.

Returns element's HTML content.

Returns

string
string
public Nette\Utils\Html
# setText( string $text )

Sets element's textual content.

Sets element's textual content.

Parameters

$text

Returns

Nette\Utils\Html
static

Throws

Nette\InvalidArgumentException
Nette\InvalidArgumentException
public string
# getText( )

Returns element's textual content.

Returns element's textual content.

Returns

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

Adds new element's child.

Adds new element's child.

Parameters

$child
node or raw HTML string

Returns

Nette\Utils\Html
static
public Nette\Utils\Html
# addHtml( Nette\Utils\Html|string $child )

Adds new element's child.

Adds new element's child.

Parameters

$child
node or raw HTML string

Returns

Nette\Utils\Html
static
public Nette\Utils\Html
# addText( string $text )

Appends plain-text string to element content.

Appends plain-text string to element content.

Parameters

$text
string

Returns

Nette\Utils\Html
static
public Nette\Utils\Html
# create( string $name, array|string $attrs = NULL )

Creates and adds a new Html child.

Creates and adds a new Html child.

Parameters

$name
name
$attrs
attributes or raw HTML string

Returns

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

Inserts child node.

Inserts child node.

Parameters

$index
or NULL for appending
$child
node or raw HTML string
$replace

Returns

Nette\Utils\Html
static

Throws

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

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

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

Parameters

$index
or NULL for appending
$child
node or raw HTML string

Implementation of

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

Returns child node (\ArrayAccess implementation).

Returns child node (\ArrayAccess implementation).

Parameters

$index

Returns

Nette\Utils\Html|string
static|string

Implementation of

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

Exists child node? (\ArrayAccess implementation).

Exists child node? (\ArrayAccess implementation).

Parameters

$index

Returns

boolean
bool

Implementation of

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

Removes child node (\ArrayAccess implementation).

Removes child node (\ArrayAccess implementation).

Parameters

$index

Implementation of

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

Returns children count.

Returns children count.

Returns

integer
int

Implementation of

Countable::count()
public
# removeChildren( )

Removes all children.

Removes all children.

public ArrayIterator
# getIterator( )

Iterates over elements.

Iterates over elements.

Returns

ArrayIterator
\ArrayIterator

Implementation of

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

Returns all children.

Returns all children.

Returns

array
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

Returns

string
string
public string
# __toString( )

Returns

string
in HTML format

Implementation of

Nette\Utils\IHtmlString::__toString()
public string
# startTag( )

Returns element's start tag.

Returns element's start tag.

Returns

string
string
public string
# endTag( )

Returns element's end tag.

Returns element's end tag.

Returns

string
string
public
# __clone( )

Clones all children too.

Clones all children too.

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

element's attributes

element's attributes

#array()
protected array $children

of Html | string nodes

of Html | string nodes

#array()
public static boolean $xhtml

use XHTML syntax?

use XHTML syntax?

#FALSE
public static array $emptyElements

empty (void) elements

empty (void) elements

#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, )
Magic properties inherited from Nette\Object
$reflection
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0