Smarty_Internal_SmartyTemplateCompiler
Class SmartyTemplateCompiler
- Full name:
\Smarty_Internal_SmartyTemplateCompiler
- Parent class:
\Smarty_Internal_TemplateCompilerBase
Properties
lexer_class
Lexer class name
parser_class
Parser class name
local_var
array of vars which can be compiled in local scope
postCompileCallbacks
array of callbacks called when the normal compile process of template is finished
prefixCompiledCode
prefix code
postfixCompiledCode
postfix code
Methods
__construct
Initialize compiler
Parameters:
Parameter | Type | Description |
---|---|---|
$lexer_class |
string | class name |
$parser_class |
string | class name |
$smarty |
\Smarty | global instance |
doCompile
method to compile a Smarty template
Parameters:
Parameter | Type | Description |
---|---|---|
$_content |
mixed | template source |
$isTemplateSource |
bool |
Return Value:
true if compiling succeeded, false if it failed
Throws:
registerPostCompileCallback
Register a post compile callback - when the callback is called after template compiling the compiler object will be inserted as first parameter
public registerPostCompileCallback(callable $callback, array $parameter = array(), string $key = null, bool $replace = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$callback |
callable | |
$parameter |
array | optional parameter array |
$key |
string | optional key for callback |
$replace |
bool | if true replace existing keyed callback |
unregisterPostCompileCallback
Remove a post compile callback
Parameters:
Parameter | Type | Description |
---|---|---|
$key |
string | callback key |
Inherited methods
__construct
Initialize compiler
Parameters:
Parameter | Type | Description |
---|---|---|
$smarty |
\Smarty | global instance |
compileTemplate
Method to compile a Smarty template
public compileTemplate(\Smarty_Internal_Template $template, bool $nocache = null, null|\Smarty_Internal_TemplateCompilerBase $parent_compiler = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$template |
\Smarty_Internal_Template | template object to compile |
$nocache |
bool | true is shall be compiled in nocache mode |
$parent_compiler |
null|\Smarty_Internal_TemplateCompilerBase |
Return Value:
true if compiling succeeded, false if it failed
Throws:
compileTemplateSource
Compile template source and run optional post filter
public compileTemplateSource(\Smarty_Internal_Template $template, null|bool $nocache = null, \Smarty_Internal_TemplateCompilerBase $parent_compiler = null): string
Parameters:
Parameter | Type | Description |
---|---|---|
$template |
\Smarty_Internal_Template | |
$nocache |
null|bool | flag if template must be compiled in nocache mode |
$parent_compiler |
\Smarty_Internal_TemplateCompilerBase |
Throws:
postFilter
Optionally process compiled code by post filter
Parameters:
Parameter | Type | Description |
---|---|---|
$code |
string | compiled code |
Throws:
preFilter
Run optional prefilter
Parameters:
Parameter | Type | Description |
---|---|---|
$_content |
string | template source |
Throws:
compileTag
Compile Tag This is a call back from the lexer/parser
Save current prefix code Compile tag Merge tag prefix code with saved one (required nested tags in attributes)
Parameters:
Parameter | Type | Description |
---|---|---|
$tag |
string | tag name |
$args |
array | array with tag attributes |
$parameter |
array | array with compilation parameter |
Return Value:
compiled code
Throws:
compileVariable
compile variable
Parameters:
Parameter | Type | Description |
---|---|---|
$variable |
string |
compileConfigVariable
compile config variable
Parameters:
Parameter | Type | Description |
---|---|---|
$variable |
string |
compilePHPFunctionCall
compile PHP function call
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$parameter |
array |
Throws:
syntaxMatchesVariable
Determines whether the passed string represents a valid (PHP) variable.
This is important, because isset()
only works on variables and empty()
can only be passed
a variable prior to php5.5
Parameters:
Parameter | Type | Description |
---|---|---|
$string |
mixed |
processText
This method is called from parser to process a text content section if strip is enabled - remove text from inheritance child templates as they may generate output
Parameters:
Parameter | Type | Description |
---|---|---|
$text |
string |
callTagCompiler
lazy loads internal compile plugin for tag and calls the compile method compile objects cached for reuse.
public callTagCompiler(string $tag, array $args, mixed $param1 = null, mixed $param2 = null, mixed $param3 = null): bool|string
class name format: Smarty_Internal_Compile_TagName plugin filename format: Smarty_Internal_TagName.php
Parameters:
Parameter | Type | Description |
---|---|---|
$tag |
string | tag name |
$args |
array | list of tag attributes |
$param1 |
mixed | optional parameter |
$param2 |
mixed | optional parameter |
$param3 |
mixed | optional parameter |
Return Value:
compiled code or false
Throws:
getTagCompiler
lazy loads internal compile plugin for tag compile objects cached for reuse.
class name format: Smarty_Internal_Compile_TagName plugin filename format: Smarty_Internal_TagName.php
Parameters:
Parameter | Type | Description |
---|---|---|
$tag |
string | tag name |
Return Value:
tag compiler object or false if not found
getPlugin
Check for plugins and return function name
Parameters:
Parameter | Type | Description |
---|---|---|
$plugin_name |
mixed | |
$plugin_type |
string | type of plugin |
Return Value:
call name of function
Throws:
getPluginFromDefaultHandler
Check for plugins by default plugin handler
Parameters:
Parameter | Type | Description |
---|---|---|
$tag |
string | name of tag |
$plugin_type |
string | type of plugin |
Return Value:
true if found
Throws:
appendCode
Append code segments and remove unneeded ?> <?php transitions
Parameters:
Parameter | Type | Description |
---|---|---|
$left |
string | |
$right |
string |
processNocacheCode
Inject inline code for nocache template sections This method gets the content of each template element from the parser.
If the content is compiled code and it should be not cached the code is injected into the rendered output.
Parameters:
Parameter | Type | Description |
---|---|---|
$content |
string | content of template element |
$is_code |
bool | true if content is compiled code |
Return Value:
content
getId
Get Id
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
string |
getVariableName
Get variable name from string
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
string |
setNocacheInVariable
Set nocache flag in variable or create new variable
Parameters:
Parameter | Type | Description |
---|---|---|
$varName |
string |
convertScope
Parameters:
Parameter | Type | Description |
---|---|---|
$_attr |
array | tag attributes |
$validScopes |
array |
Throws:
makeNocacheCode
Generate nocache code string
Parameters:
Parameter | Type | Description |
---|---|---|
$code |
string | PHP code |
trigger_template_error
display compiler error messages without dying If parameter $args is empty it is a parser detected syntax error.
public trigger_template_error(string $args = null, string $line = null, null|bool $tagline = null): mixed
In this case the parser is called to obtain information about expected tokens. If parameter $args contains a string this is used as error message
Parameters:
Parameter | Type | Description |
---|---|---|
$args |
string | individual error message or null |
$line |
string | line-number |
$tagline |
null|bool | if true the line number of last tag |
Throws:
when an unexpected token is found
getVarExport
Return var_export() value with all white spaces removed
Parameters:
Parameter | Type | Description |
---|---|---|
$value |
mixed |
enterDoubleQuote
enter double quoted string - save tag stack count
getTagStackCount
Return tag stack count
replaceDelimiter
Parameters:
Parameter | Type | Description |
---|---|---|
$lexerPreg |
mixed |
initDelimiterPreg
Build lexer regular expressions for left and right delimiter and user defined literals
leaveDoubleQuote
leave double quoted string - throw exception if block in string was not closed
Throws:
getLdelPreg
Get left delimiter preg
getRdelPreg
Get right delimiter preg
getLdelLength
Get length of left delimiter
getRdelLength
Get length of right delimiter
getOpenBlockTag
Get name of current open block tag
isVariable
Check if $value contains variable elements
Parameters:
Parameter | Type | Description |
---|---|---|
$value |
mixed |
getNewPrefixVariable
Get new prefix variable name
getPrefixVariable
Get current prefix variable name
appendPrefixCode
append code to prefix buffer
Parameters:
Parameter | Type | Description |
---|---|---|
$code |
string |
getPrefixCode
get prefix code string
saveRequiredPlugins
Save current required plugins
Parameters:
Parameter | Type | Description |
---|---|---|
$init |
bool | if true init required plugins |
restoreRequiredPlugins
Restore required plugins
compileRequiredPlugins
Compile code to call Smarty_Internal_Template::_checkPlugins() for required plugins
compileCheckPlugins
Compile code to call Smarty_Internal_Template::_checkPlugins - checks if plugin is callable require otherwise
Parameters:
Parameter | Type | Description |
---|---|---|
$requiredPlugins |
mixed |
doCompile
method to compile a Smarty template
- This method is abstract.
Parameters:
Parameter | Type | Description |
---|---|---|
$_content |
mixed | template source |
$isTemplateSource |
bool |
Return Value:
true if compiling succeeded, false if it failed
cStyleComment
Parameters:
Parameter | Type | Description |
---|---|---|
$string |
mixed |
compileTag2
Compile Tag
Parameters:
Parameter | Type | Description |
---|---|---|
$tag |
string | tag name |
$args |
array | array with tag attributes |
$parameter |
array | array with compilation parameter |
Return Value:
compiled code
Throws:
Automatically generated on 2025-03-18