Class Twig_Compiler

InheritanceTwig_Compiler
ImplementsTwig_CompilerInterface

Compiles a node to PHP code.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. Twig_Compiler
addDebugInfo() Adds debugging information. Twig_Compiler
addIndentation() Appends an indentation to the current PHP code after compilation. Twig_Compiler
compile() Compiles a node. Twig_Compiler
getDebugInfo() Twig_Compiler
getEnvironment() Returns the environment instance related to this compiler. Twig_Compiler
getFilename() Twig_Compiler
getSource() Gets the current PHP code after compilation. Twig_Compiler
getVarName() Twig_Compiler
indent() Indents the generated code. Twig_Compiler
outdent() Outdents the generated code. Twig_Compiler
raw() Adds a raw string to the compiled code. Twig_Compiler
repr() Returns a PHP representation of a given value. Twig_Compiler
string() Adds a quoted string to the compiled code. Twig_Compiler
subcompile() Twig_Compiler
write() Writes a string to the compiled code by adding indentation. Twig_Compiler

Property Details

$debugInfo protected property
protected $debugInfo = []
$env protected property
protected $env null
$filename protected property
protected $filename null
$indentation protected property
protected $indentation null
$lastLine protected property
protected $lastLine null
$source protected property
protected $source null
$sourceLine protected property
protected $sourceLine null
$sourceOffset protected property
protected $sourceOffset null

Method Details

__construct() public method

Constructor.

public void __construct ( Twig_Environment $env )
$env Twig_Environment

The twig environment instance

addDebugInfo() public method

Adds debugging information.

public Twig_Compiler addDebugInfo ( Twig_NodeInterface $node )
$node Twig_NodeInterface

The related twig node

return Twig_Compiler

The current compiler instance

addIndentation() public method

Appends an indentation to the current PHP code after compilation.

public Twig_Compiler addIndentation ( )
return Twig_Compiler

The current compiler instance

compile() public method

Compiles a node.

public Twig_Compiler compile ( Twig_NodeInterface $node, $indentation 0 )
$node Twig_NodeInterface

The node to compile

$indentation int

The current indentation

return Twig_Compiler

The current compiler instance

getDebugInfo() public method

public void getDebugInfo ( )
getEnvironment() public method

Returns the environment instance related to this compiler.

public Twig_Environment getEnvironment ( )
return Twig_Environment

The environment instance

getFilename() public method

public void getFilename ( )
getSource() public method

Gets the current PHP code after compilation.

public string getSource ( )
return string

The PHP code

getVarName() public method

public void getVarName ( )
indent() public method

Indents the generated code.

public Twig_Compiler indent ( $step 1 )
$step int

The number of indentation to add

return Twig_Compiler

The current compiler instance

outdent() public method

Outdents the generated code.

public Twig_Compiler outdent ( $step 1 )
$step int

The number of indentation to remove

return Twig_Compiler

The current compiler instance

throws LogicException

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

raw() public method

Adds a raw string to the compiled code.

public Twig_Compiler raw ( $string )
$string string

The string

return Twig_Compiler

The current compiler instance

repr() public method

Returns a PHP representation of a given value.

public Twig_Compiler repr ( $value )
$value mixed

The value to convert

return Twig_Compiler

The current compiler instance

string() public method

Adds a quoted string to the compiled code.

public Twig_Compiler string ( $value )
$value string

The string

return Twig_Compiler

The current compiler instance

subcompile() public method

public void subcompile ( Twig_NodeInterface $node, $raw true )
$node
$raw
write() public method

Writes a string to the compiled code by adding indentation.

public Twig_Compiler write ( )
return Twig_Compiler

The current compiler instance