Twig API
Class

Twig_Node

class Twig_Node implements Twig_NodeInterface

Represents a node in the AST.

Methods

__construct(array $nodes = array(), array $attributes = array(), integer $lineno, string $tag = null)

Constructor.

__toString()

toXml($asDom = false)

compile(Twig_Compiler $compiler)

Compiles the node to PHP.

getLine()

getNodeTag()

Boolean hasAttribute(string $name)

Returns true if the attribute is defined.

mixed getAttribute(string $name)

Gets an attribute.

setAttribute(string $name, mixed $value)

Sets an attribute.

removeAttribute(string $name)

Removes an attribute.

Boolean hasNode(string $name)

Returns true if the node with the given identifier exists.

Twig_Node getNode(string $name)

Gets a node by name.

setNode(string $name, Twig_Node $node = null)

Sets a node.

removeNode(string $name)

Removes a node by name.

count()

getIterator()

Details

at line 36
public __construct(array $nodes = array(), array $attributes = array(), integer $lineno, string $tag = null)

Constructor.

The nodes are automatically made available as properties ($this->node).
The attributes are automatically made available as array items ($this['name']).

Parameters

array $nodes An array of named nodes
array $attributes An array of attributes (should not be nodes)
integer $lineno The line number
string $tag The tag name associated with the Node

at line 44
public __toString()

at line 72
public toXml($asDom = false)

Parameters

$asDom

at line 102
public compile(Twig_Compiler $compiler)

Compiles the node to PHP.

Parameters

Twig_Compiler $compiler A Twig_Compiler instance

at line 109
public getLine()

at line 114
public getNodeTag()

at line 126
public Boolean hasAttribute(string $name)

Returns true if the attribute is defined.

Parameters

string $name The attribute name

Return Value

Boolean true if the attribute is defined, false otherwise

at line 138
public mixed getAttribute(string $name)

Gets an attribute.

Parameters

string $name The attribute name

Return Value

mixed The attribute value

at line 153
public setAttribute(string $name, mixed $value)

Sets an attribute.

Parameters

string $name The attribute name
mixed $value The attribute value

at line 163
public removeAttribute(string $name)

Removes an attribute.

Parameters

string $name The attribute name

at line 175
public Boolean hasNode(string $name)

Returns true if the node with the given identifier exists.

Parameters

string $name The node name

Return Value

Boolean true if the node with the given name exists, false otherwise

at line 187
public Twig_Node getNode(string $name)

Gets a node by name.

Parameters

string $name The node name

Return Value

Twig_Node A Twig_Node instance

at line 202
public setNode(string $name, Twig_Node $node = null)

Sets a node.

Parameters

string $name The node name
Twig_Node $node A Twig_Node instance

at line 212
public removeNode(string $name)

Removes a node by name.

Parameters

string $name The node name

at line 217
public count()

at line 222
public getIterator()