Smarty_Internal_TemplateCompilerBase
Main abstract compiler class
- Full name:
\Smarty_Internal_TemplateCompilerBase
- This class is an Abstract class
Properties
_tag_objects
compile tag objects cache
- This property is static.
prefixVariableNumber
counter for prefix variable number
- This property is static.
smarty
Smarty object
parser
Parser object
nocache_hash
hash for nocache sections
suppressNocacheProcessing
suppress generation of nocache code
caching
caching enabled (copied from template object)
_tag_stack
tag stack
_tag_stack_count
tag stack count
required_plugins
Plugins used by template
required_plugins_stack
Required plugins stack
template
current template
mergedSubTemplatesData
merged included sub template data
mergedSubTemplatesCode
merged sub template code
templateProperties
collected template properties during compilation
trace_line_offset
source line offset for error messages
trace_uid
trace uid
trace_filepath
trace file path
trace_stack
stack for tracing file and line of nested {block} tags
default_handler_plugins
plugins loaded by default plugin handler
default_modifier_list
saved preprocessed modifier list
forceNocache
force compilation of complete template as nocache
write_compiled_code
flag if compiled template file shall we written
tpl_function
Template functions
called_functions
called sub functions from template function
blockOrFunctionCode
compiled template or block function code
modifier_plugins
flags for used modifier plugins
known_modifier_type
type of already compiled modifier
parent_compiler
parent compiler object for merged subtemplates and template functions
nocache
Flag true when compiling nocache section
tag_nocache
Flag true when tag is compiled as nocache
prefix_code
Compiled tag prefix code
usedPrefixVariables
used prefix variables by current compiled tag
prefixCodeStack
Prefix code stack
has_code
Tag has compiled code
has_variable_string
A variable string was compiled
variable_filter_stack
Stack for {setfilter} {/setfilter}
variable_filters
variable filters for {setfilter} {/setfilter}
loopNesting
Nesting count of looping tags like {foreach}, {for}, {section}, {while}
stripRegEx
Strip preg pattern
plugin_search_order
plugin search order
_cache
General storage area for tag compiler plugins
ldelPreg
Lexer preg pattern for left delimiter
rdelPreg
Lexer preg pattern for right delimiter
rdelLength
Length of right delimiter
ldelLength
Length of left delimiter
literalPreg
Lexer preg pattern for user literals
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