\Pluf_Template_Compiler

Class to compile a template file into the corresponding PHP script to be run by the Template class.

Compiler dataflow

The important elements of the compiler are the include extends block and superblock directives. They cannot be handled in a linear way like the rest of the elements, they are more like nodes.

Summary

Methods
Properties
Constants
__construct()
compile()
getCompiledTemplate()
compileBlocks()
loadTemplateFile()
_callback()
_parseVariable()
_parseFunction()
_parseFinal()
$_usedModifiers
$templateFolders
$templateContent
$_extendBlocks
$_extendedTemplate
No constants found
updateModifierStack()
$_literals
$_vartype
$_assignOp
$_op
$_allowedInVar
$_allowedInExpr
$_allowedAssign
$_modifier
$_allowedTags
$_extraTags
$_blockStack
$_transStack
$_transPlural
$_sourceFile
$_currentTag
N/A
No private methods found
No private properties found
N/A

Properties

$_usedModifiers

$_usedModifiers : 

After the compilation is completed, this contains the list of modifiers used in the template.

The GetCompiledTemplate method will add a series of Pluf::loadFunction at the top to preload these modifiers.

Type

$templateFolders

$templateFolders : 

Template folders.

Type

$templateContent

$templateContent : 

Template content.

It can be set directly from a string.

Type

$_extendBlocks

$_extendBlocks : 

The extend blocks.

Type

$_extendedTemplate

$_extendedTemplate : 

The extended template.

Type

$_literals

$_literals : 

Store the literal blocks.

Type

$_vartype

$_vartype : 

Variables.

Type

$_assignOp

$_assignOp : 

Assignation operators.

Type

$_op

$_op : 

Operators.

Type

$_allowedInVar

$_allowedInVar : 

Authorized elements in variables.

Type

$_allowedInExpr

$_allowedInExpr : 

Authorized elements in expression.

Type

$_allowedAssign

$_allowedAssign : 

Authorized elements in assignation.

Type

$_modifier

$_modifier : 

Output filters.

Type

$_allowedTags

$_allowedTags : 

Default allowed extra tags/functions.

These default tags are merged with the 'template_tags' defined in the configuration of the application.

Type

$_extraTags

$_extraTags : 

During compilation, all the tags are created once so to query their interface easily.

Type

$_blockStack

$_blockStack : 

The block stack to see if the blocks are correctly closed.

Type

$_transStack

$_transStack : 

Special stack for the translation handling in blocktrans.

Type

$_transPlural

$_transPlural : 

Type

$_sourceFile

$_sourceFile : 

Current template source file.

Type

$_currentTag

$_currentTag : 

Current tag.

Type

Methods

__construct()

__construct(  $template_file,   $folders = array(),   $load = true) 

Construct the compiler.

Parameters

$template_file
$folders
$load

compile()

compile() : string

Compile the template into a PHP code.

Returns

string —

PHP code of the compiled template.

getCompiledTemplate()

getCompiledTemplate() 

Get a cleaned compile template.

compileBlocks()

compileBlocks() 

Parse the extend blocks.

If the current template extends another, it finds the extended template and grabs the defined blocks and compile them.

loadTemplateFile()

loadTemplateFile(  $file) 

Load a template file.

The path to the file to load is relative and the file is found in one of the $templateFolders array of folders.

Parameters

$file

_callback()

_callback(  $matches) 

Parameters

$matches

_parseVariable()

_parseVariable(  $expr) 

Parameters

$expr

_parseFunction()

_parseFunction(  $name,   $args) 

Parameters

$name
$args

_parseFinal()

_parseFinal(  $string,   $allowed = array(),   $exceptchar = array(';'),   $getAsArray = false) 

Parameters

$string
$allowed
$exceptchar
$getAsArray

updateModifierStack()

updateModifierStack(  $compiler) 

Update the current stack of modifiers from another compiler.

Parameters

$compiler