jTplCompiler

Implements \jISimpleCompiler

This is the compiler of templates: it converts a template into a php file.

package

jelix

subpackage

jtpl

Methods

Initialize some properties

__construct() 

function called during the parsing of the template by a preg_replace_callback function It is called on each template tag {xxxx }

_callback(array $matches) : string
Throws
\Exception
\jException

Arguments

$matches

array

a matched item

Response

string

the corresponding php code of the tag (with php tag).

Try to find a plugin

_getPlugin(string $type, string $name) : array|boolean

Arguments

$type

string

type of plugin (function, modifier...)

$name

string

the plugin name

Response

array|boolean

an array containing the path of the plugin and the name of the plugin function, or false if not found

sub-function which analyse an expression

_parseFinal(string $string, array $allowed = array(), array $exceptchar = array(';'), boolean $splitArgIntoArray = false,  $sep1 = ',',  $sep2 = ',') : array|string

Arguments

$string

string

the expression

$allowed

array

list of allowed php token

$exceptchar

array

list of forbidden characters

$splitArgIntoArray

boolean

true: split the results on coma

$sep1

$sep2

Response

array|string

analyse the tag which have a name

_parseFunction(string $name, string $args) : string

Arguments

$name

string

the name of the tag

$args

string

the content that follow the name in the tag

Response

string

the corresponding php instructions

_parseMeta

_parseMeta( $args,  $fct = '') 

Arguments

$args

$fct

analyse an "echo" tag : {$.

_parseVariable(string $expr) : string

.} or {@..}

Arguments

$expr

string

the content of the tag

Response

string

the corresponding php instruction

addMetaContent

addMetaContent( $content) 

Arguments

$content

Launch the compilation of a template

compile(\jSelectorTpl $selector) : boolean

Store the result (a php content) into a cache file given by the selector.

Arguments

$selector

\jSelectorTpl

the template selector

Response

boolean

true if ok

compileContent

compileContent( $tplcontent) 

Arguments

$tplcontent

compileString

compileString( $templatecontent,  $cachefile,  $userModifiers,  $userFunctions,  $md5,  $header = '',  $footer = '') 

Arguments

$templatecontent

$cachefile

$userModifiers

$userFunctions

$md5

$header

$footer

doError0

doError0( $err) 

Arguments

$err

doError1

doError1( $err,  $arg) 

Arguments

$err

$arg

doError2

doError2( $err,  $arg1,  $arg2) 

Arguments

$err

$arg1

$arg2

for plugins, it says if the plugin is inside the given block

isInsideBlock(string $blockName, boolean $onlyUpper = false) : boolean

Arguments

$blockName

string

the block to search

$onlyUpper

boolean

check only the upper block

Response

boolean

true if it is inside the block

Properties

_literals

_literals : 

Type(s)

tokens of variable type

_vartype : 

Type(s)

tokens of operators for assignements

_assignOp : 

Type(s)

tokens of operators for tests

_op : 

Type(s)

tokens authorized into locale names

_inLocaleOk : 

Type(s)

tokens allowed in output for variables

_allowedInVar : 

Type(s)

tokens allowed into expressions

_allowedInExpr : 

Type(s)

tokens allowed into assignements

_allowedAssign : 

Type(s)

tokens allowed in foreach statements

_allowedInForeach : 

Type(s)

tokens not allowed in variable

_excludedInVar : 

Type(s)

_allowedConstants

_allowedConstants : 

Type(s)

list of plugins paths

_pluginPath : 

Type(s)

_metaBody

_metaBody : 

Type(s)

native modifiers

_modifier : 

Type(s)

stack of founded blocks

_blockStack : 

Type(s)

name of the template file

_sourceFile : 

Type(s)

current parsed jtpl tag

_currentTag : 

Type(s)

type of the output

outputType : 

Type(s)

true if the template doesn't come from an untrusted source.

trusted : 

if it comes from an untrusted source, like a template uploaded by a user, you should set to false.

Type(s)

list of user functions

_userFunctions : 

Type(s)

removeASPtags

removeASPtags : 

Type(s)