Jelix 1.6.40

jTplCompiler
in package
implements jISimpleCompiler

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

Tags
subpackage

jtpl

Interfaces, Classes and Traits

jISimpleCompiler
interface for compiler which needs only one source file.

Table of Contents

$outputType  : mixed
type of the output
$trusted  : mixed
true if the template doesn't come from an untrusted source.
$_allowedAssign  : mixed
tokens allowed into assignements
$_allowedConstants  : mixed
$_allowedInExpr  : mixed
tokens allowed into expressions
$_allowedInForeach  : mixed
tokens allowed in foreach statements
$_allowedInVar  : mixed
tokens allowed in output for variables
$_excludedInVar  : mixed
tokens not allowed in variable
$_metaBody  : mixed
$_modifier  : mixed
native modifiers
$_userFunctions  : mixed
list of user functions
$removeASPtags  : mixed
$_assignOp  : mixed
tokens of operators for assignements
$_blockStack  : mixed
stack of founded blocks
$_currentTag  : mixed
current parsed jtpl tag
$_inLocaleOk  : mixed
tokens authorized into locale names
$_literals  : mixed
$_op  : mixed
tokens of operators for tests
$_pluginPath  : mixed
list of plugins paths
$_sourceFile  : mixed
name of the template file
$_vartype  : mixed
tokens of variable type
__construct()  : mixed
Initialize some properties
_callback()  : string
function called during the parsing of the template by a preg_replace_callback function It is called on each template tag {xxxx }
addMetaContent()  : mixed
compile()  : bool
Launch the compilation of a template
compileString()  : mixed
doError0()  : mixed
doError1()  : mixed
doError2()  : mixed
isInsideBlock()  : bool
for plugins, it says if the plugin is inside the given block
_getPlugin()  : array<string|int, mixed>|bool
Try to find a plugin
_parseFinal()  : array<string|int, mixed>|string
sub-function which analyse an expression
_parseFunction()  : string
analyse the tag which have a name
_parseMeta()  : mixed
_parseVariable()  : string
analyse an "echo" tag : {$..} or {@..}
compileContent()  : mixed

Properties

$trusted

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

public mixed $trusted = rue

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

$_allowedAssign

tokens allowed into assignements

protected mixed $_allowedAssign

$_allowedConstants

protected mixed $_allowedConstants = array('TRUE', 'FALSE', 'NULL', 'M_1_PI', 'M_2_PI', 'M_2_SQRTPI', 'M_E', 'M_LN10', 'M_LN2', 'M_LOG10E', 'M_LOG2E', 'M_PI', 'M_PI_2', 'M_PI_4', 'M_SQRT1_2', 'M_SQRT2')

$_allowedInForeach

tokens allowed in foreach statements

protected mixed $_allowedInForeach

$_allowedInVar

tokens allowed in output for variables

protected mixed $_allowedInVar

$_excludedInVar

tokens not allowed in variable

protected mixed $_excludedInVar = array(';', '=')

$_modifier

native modifiers

protected mixed $_modifier = array('upper' => 'strtoupper', 'lower' => 'strtolower', 'escxml' => 'htmlspecialchars', 'eschtml' => 'htmlspecialchars', 'strip_tags' => 'strip_tags', 'escurl' => 'rawurlencode', 'capitalize' => 'ucwords', 'stripslashes' => 'stripslashes', 'upperfirst' => 'ucfirst', 'json_encode' => 'json_encode')

$_userFunctions

list of user functions

protected mixed $_userFunctions = array()

$_assignOp

tokens of operators for assignements

private mixed $_assignOp = array(T_AND_EQUAL, T_DIV_EQUAL, T_MINUS_EQUAL, T_MOD_EQUAL, T_MUL_EQUAL, T_OR_EQUAL, T_PLUS_EQUAL, T_PLUS_EQUAL, T_SL_EQUAL, T_SR_EQUAL, T_XOR_EQUAL)

$_inLocaleOk

tokens authorized into locale names

private mixed $_inLocaleOk = array(T_STRING, T_ABSTRACT, T_AS, T_BREAK, T_CASE, T_CATCH, T_CLASS, T_CLONE, T_CONST, T_CONTINUE, T_DECLARE, T_DEFAULT, T_DNUMBER, T_DO, T_ECHO, T_ELSE, T_ELSEIF, T_EMPTY, T_ENDIF, T_ENDFOR, T_EVAL, T_EXIT, T_EXTENDS, T_FINAL, T_FOR, T_FOREACH, T_FUNCTION, T_GLOBAL, T_GOTO, T_IF, T_IMPLEMENTS, T_INCLUDE, T_INSTANCEOF, T_INTERFACE, T_LIST, T_LNUMBER, T_LOGICAL_AND, T_LOGICAL_OR, T_LOGICAL_XOR, T_NAMESPACE, T_NEW, T_PRINT, T_PRIVATE, T_PUBLIC, T_PROTECTED, T_REQUIRE, T_RETURN, T_STATIC, T_SWITCH, T_THROW, T_TRY, T_USE, T_VAR, T_WHILE)

$_op

tokens of operators for tests

private mixed $_op = array(T_BOOLEAN_AND, T_BOOLEAN_OR, T_EMPTY, T_INC, T_DEC, T_ISSET, T_IS_EQUAL, T_IS_GREATER_OR_EQUAL, T_IS_IDENTICAL, T_IS_NOT_EQUAL, T_IS_NOT_IDENTICAL, T_IS_SMALLER_OR_EQUAL, T_LOGICAL_AND, T_LOGICAL_OR, T_LOGICAL_XOR, T_SR, T_SL, T_DOUBLE_ARROW)

$_vartype

tokens of variable type

private mixed $_vartype = array(T_CONSTANT_ENCAPSED_STRING, T_DNUMBER, T_ENCAPSED_AND_WHITESPACE, T_LNUMBER, T_OBJECT_OPERATOR, T_STRING, T_WHITESPACE, T_ARRAY)

Methods

__construct()

Initialize some properties

public __construct() : mixed
Return values
mixed

_callback()

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

public _callback(array<string|int, mixed> $matches) : string
Parameters
$matches : array<string|int, mixed>

a matched item

Tags
throws
Exception
throws
jException
Return values
string

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

addMetaContent()

public addMetaContent(mixed $content) : mixed
Parameters
$content : mixed
Return values
mixed

compile()

Launch the compilation of a template

public compile(jSelectorTpl $selector) : bool

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

Parameters
$selector : jSelectorTpl

the template selector

Return values
bool

true if ok

compileString()

public compileString(mixed $templatecontent, mixed $cachefile, mixed $userModifiers, mixed $userFunctions, mixed $md5[, mixed $header = '' ][, mixed $footer = '' ]) : mixed
Parameters
$templatecontent : mixed
$cachefile : mixed
$userModifiers : mixed
$userFunctions : mixed
$md5 : mixed
$header : mixed = ''
$footer : mixed = ''
Return values
mixed

doError0()

public doError0(mixed $err) : mixed
Parameters
$err : mixed
Return values
mixed

doError1()

public doError1(mixed $err, mixed $arg) : mixed
Parameters
$err : mixed
$arg : mixed
Return values
mixed

doError2()

public doError2(mixed $err, mixed $arg1, mixed $arg2) : mixed
Parameters
$err : mixed
$arg1 : mixed
$arg2 : mixed
Return values
mixed

isInsideBlock()

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

public isInsideBlock(string $blockName[, bool $onlyUpper = false ]) : bool
Parameters
$blockName : string

the block to search

$onlyUpper : bool = false

check only the upper block

Return values
bool

true if it is inside the block

_getPlugin()

Try to find a plugin

protected _getPlugin(string $type, string $name) : array<string|int, mixed>|bool
Parameters
$type : string

type of plugin (function, modifier...)

$name : string

the plugin name

Return values
array<string|int, mixed>|bool

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

_parseFinal()

sub-function which analyse an expression

protected _parseFinal(string $string[, array<string|int, mixed> $allowed = array() ][, array<string|int, mixed> $exceptchar = array(';') ][, bool $splitArgIntoArray = false ][, mixed $sep1 = ',' ][, mixed $sep2 = ',' ]) : array<string|int, mixed>|string
Parameters
$string : string

the expression

$allowed : array<string|int, mixed> = array()

list of allowed php token

$exceptchar : array<string|int, mixed> = array(';')

list of forbidden characters

$splitArgIntoArray : bool = false

true: split the results on coma

$sep1 : mixed = ','
$sep2 : mixed = ','
Return values
array<string|int, mixed>|string

_parseFunction()

analyse the tag which have a name

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

the name of the tag

$args : string

the content that follow the name in the tag

Return values
string

the corresponding php instructions

_parseMeta()

protected _parseMeta(mixed $args[, mixed $fct = '' ]) : mixed
Parameters
$args : mixed
$fct : mixed = ''
Return values
mixed

_parseVariable()

analyse an "echo" tag : {$..} or {@..}

protected _parseVariable(string $expr) : string
Parameters
$expr : string

the content of the tag

Return values
string

the corresponding php instruction

compileContent()

protected compileContent(mixed $tplcontent) : mixed
Parameters
$tplcontent : mixed
Return values
mixed

Search results