class Twig_Compiler

Compiles a node to PHP code.

Methods

__construct(Twig_Environment $env)

No description

getEnvironment()

Returns the environment instance related to this compiler.

string
getSource()

Gets the current PHP code after compilation.

$this
compile(Twig_Node $node, int $indentation)

Compiles a node.

subcompile(Twig_Node $node, $raw = true)

No description

$this
raw(string $string)

Adds a raw string to the compiled code.

$this
write($strings)

Writes a string to the compiled code by adding indentation.

$this
string(string $value)

Adds a quoted string to the compiled code.

$this
repr(mixed $value)

Returns a PHP representation of a given value.

$this
addDebugInfo(Twig_Node $node)

Adds debugging information.

getDebugInfo()

No description

$this
indent(int $step = 1)

Indents the generated code.

$this
outdent(int $step = 1)

Outdents the generated code.

getVarName()

No description

Details

at line 28
__construct(Twig_Environment $env)

Parameters

Twig_Environment $env

at line 38
Twig_Environment getEnvironment()

Returns the environment instance related to this compiler.

Return Value

Twig_Environment

at line 48
string getSource()

Gets the current PHP code after compilation.

Return Value

string The PHP code

at line 61
$this compile(Twig_Node $node, int $indentation)

Compiles a node.

Parameters

Twig_Node $node The node to compile
int $indentation The current indentation

Return Value

$this

at line 76
subcompile(Twig_Node $node, $raw = true)

Parameters

Twig_Node $node
$raw

at line 94
$this raw(string $string)

Adds a raw string to the compiled code.

Parameters

string $string The string

Return Value

$this

at line 106
$this write($strings)

Writes a string to the compiled code by adding indentation.

Parameters

$strings

Return Value

$this

at line 122
$this string(string $value)

Adds a quoted string to the compiled code.

Parameters

string $value The string

Return Value

$this

at line 136
$this repr(mixed $value)

Returns a PHP representation of a given value.

Parameters

mixed $value The value to convert

Return Value

$this

at line 177
$this addDebugInfo(Twig_Node $node)

Adds debugging information.

Parameters

Twig_Node $node

Return Value

$this

at line 192
getDebugInfo()

at line 206
$this indent(int $step = 1)

Indents the generated code.

Parameters

int $step The number of indentation to add

Return Value

$this

at line 222
$this outdent(int $step = 1)

Outdents the generated code.

Parameters

int $step The number of indentation to remove

Return Value

$this

Exceptions

LogicException When trying to outdent too much so the indentation would become negative

at line 234
getVarName()