API Documentation for: 1.1.1
Show:

Text Class

Extends Node
Namespace: Canteen\HTML5

Special Node representing plain text. Do not initiate this class directly, it is created whenever a text is passed into a container tag:

echo html('p', 'Some Text Here');

Constructor

Text

(
  • text
)

Parameters:

  • text String

    the plain text string

Methods

__get

(
  • name
)

Inherited from Node:

General purpose getter to get attribute values

Parameters:

  • name String

    The name of the property to set

__isset

(
  • name
)

Inherited from Node:

See if a property exists

Parameters:

  • name String

    The name of the attribute

__set

(
  • name
  • value
)

Inherited from Node:

General purpose setter to set attribute values

Parameters:

  • name String

    The name of the attribute

  • value String

    The value of the attribute

__toString

() String

Inherited from Node

Write to HTML

Returns:

String:

The string representation of this HTML node

appendTo

(
  • container
)
Node

Inherited from Node:

Add this child to a node container at the end

Parameters:

Returns:

Node:

The instance of this Node

getAttribute

(
  • [name=null]
)
String

Inherited from Node:

Fetch and attribute by name from this Node. The attribute name cannot be null; if so, this function will throw an Exception.

Parameters:

  • [name=null] String optional

    The name of the attribute to fetch

Returns:

String:

The attribute's value, if any or null

getData

(
  • name
)
String

Inherited from Node:

Get the data-* HTML5 attribute value, if set

Parameters:

  • name String

    The name of the data attribute

Returns:

String:

The value of the data

getParent

() NodeContainer private

Inherited from Node:

Returns the parent node of this node, if a parent exists. If no parent exists, this function returns null.

Returns:

NodeContainer:

The parent node object

isEmpty

(
  • var
)
protected

Inherited from Node:

Checks if a variable is really "empty". Code borrowed from PHP.net at http://us3.php.net/manual/en/function.empty.php#90767 because we were previously using empty() to see if a variable is empty or not. But empty() dosen't work for attributes that have a value of "0", so we need something more robust here.

  • an unset variable -> empty
  • null -> empty
  • 0 -> NOT empty
  • "0" -> NOT empty
  • false -> empty
  • true -> NOT empty
  • 'string value' -> NOT empty
  • " "(white space) -> empty
  • array()(empty array) -> empty

Parameters:

  • var Mixed

    The variable to check for empty on

prependTo

(
  • container
)
Node

Inherited from Node:

Add this child to the beginning of a node container

Parameters:

Returns:

Node:

The instance of this Node

setAttribute

(
  • [name=null]
  • [value=null]
  • The
)

Inherited from Node:

Given a name and value pair, sets an attribute on this Node. The name and value cannot be empty; if so, this function will throw an Exception. Note if the attribute already exists and the caller wants to set an attribute of the same name, this function will not create a new Attribute, but rather update the value of the existing named attribute.

Parameters:

  • [name=null] String optional

    The name of the attribute to add

  • [value=null] String optional

    The value of the attribute

  • The Node

    instance of this node

setAttributes

(
  • values
)
Node

Inherited from Node:

Set the list of all attributes.

Parameters:

  • values Dictionary

    An attributes array(name=>value, name=>value)

Returns:

Node:

The instance of this Node

setParent

(
  • [parent=null]
)
protected

Inherited from Node:

Sets the parent of this Node. Note that this function is protected and can only be called by classes that extend Node. The parent cannot be null; this function will throw an Exception if the parent node is empty.

Parameters:

writeOpen

(
  • [selfClose=true]
)
String protected

Inherited from Node:

Start the writing the tag

Parameters:

  • [selfClose=true] Boolean optional

    If the tag is a self closing tag (e.g., br, img, hr)

Returns:

String:

The buffer of HTML

Properties

_attributes

Array protected

Inherited from Node:

The collection of Attributes objects

_parent

NodeContainer protected

Inherited from Node:

The parent node, if any

_tag

String protected

Inherited from Node:

The string name of the tag

_validAttrs

Array protected

Inherited from Node:

The collection of valid attributes names for given tag