Skip to content

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

public static array $_tag_objects
  • This property is static.

prefixVariableNumber

counter for prefix variable number

public static int $prefixVariableNumber
  • This property is static.

smarty

Smarty object

public \Smarty $smarty

parser

Parser object

public \Smarty_Internal_Templateparser $parser

nocache_hash

hash for nocache sections

public mixed $nocache_hash

suppressNocacheProcessing

suppress generation of nocache code

public bool $suppressNocacheProcessing

caching

caching enabled (copied from template object)

public int $caching

_tag_stack

tag stack

public array $_tag_stack

_tag_stack_count

tag stack count

public array $_tag_stack_count

required_plugins

Plugins used by template

public array $required_plugins

required_plugins_stack

Required plugins stack

public array $required_plugins_stack

template

current template

public \Smarty_Internal_Template $template

mergedSubTemplatesData

merged included sub template data

public array $mergedSubTemplatesData

mergedSubTemplatesCode

merged sub template code

public array $mergedSubTemplatesCode

templateProperties

collected template properties during compilation

public array $templateProperties

trace_line_offset

source line offset for error messages

public int $trace_line_offset

trace_uid

trace uid

public string $trace_uid

trace_filepath

trace file path

public string $trace_filepath

trace_stack

stack for tracing file and line of nested {block} tags

public array $trace_stack

default_handler_plugins

plugins loaded by default plugin handler

public array $default_handler_plugins

default_modifier_list

saved preprocessed modifier list

public mixed $default_modifier_list

forceNocache

force compilation of complete template as nocache

public bool $forceNocache

write_compiled_code

flag if compiled template file shall we written

public bool $write_compiled_code

tpl_function

Template functions

public array $tpl_function

called_functions

called sub functions from template function

public array $called_functions

blockOrFunctionCode

compiled template or block function code

public string $blockOrFunctionCode

modifier_plugins

flags for used modifier plugins

public array $modifier_plugins

known_modifier_type

type of already compiled modifier

public array $known_modifier_type

parent_compiler

parent compiler object for merged subtemplates and template functions

public \Smarty_Internal_TemplateCompilerBase $parent_compiler

nocache

Flag true when compiling nocache section

public bool $nocache

tag_nocache

Flag true when tag is compiled as nocache

public bool $tag_nocache

prefix_code

Compiled tag prefix code

public array $prefix_code

usedPrefixVariables

used prefix variables by current compiled tag

public array $usedPrefixVariables

prefixCodeStack

Prefix code stack

public array $prefixCodeStack

has_code

Tag has compiled code

public bool $has_code

has_variable_string

A variable string was compiled

public bool $has_variable_string

variable_filter_stack

Stack for {setfilter} {/setfilter}

public array $variable_filter_stack

variable_filters

variable filters for {setfilter} {/setfilter}

public array $variable_filters

loopNesting

Nesting count of looping tags like {foreach}, {for}, {section}, {while}

public int $loopNesting

stripRegEx

Strip preg pattern

public string $stripRegEx

plugin_search_order

plugin search order

public array $plugin_search_order

_cache

General storage area for tag compiler plugins

public array $_cache

ldelPreg

Lexer preg pattern for left delimiter

private string $ldelPreg

rdelPreg

Lexer preg pattern for right delimiter

private string $rdelPreg

rdelLength

Length of right delimiter

private int $rdelLength

ldelLength

Length of left delimiter

private int $ldelLength

literalPreg

Lexer preg pattern for user literals

private string $literalPreg

Methods

__construct

Initialize compiler

public __construct(\Smarty $smarty): mixed

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

public postFilter(string $code): string

Parameters:

Parameter Type Description
$code string compiled code

Throws:


preFilter

Run optional prefilter

public preFilter(string $_content): string

Parameters:

Parameter Type Description
$_content string template source

Throws:


compileTag

Compile Tag This is a call back from the lexer/parser

public compileTag(string $tag, array $args, array $parameter = array()): string

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

public compileVariable(string $variable): string

Parameters:

Parameter Type Description
$variable string

compileConfigVariable

compile config variable

public compileConfigVariable(string $variable): string

Parameters:

Parameter Type Description
$variable string

compilePHPFunctionCall

compile PHP function call

public compilePHPFunctionCall(string $name, array $parameter): string

Parameters:

Parameter Type Description
$name string
$parameter array

Throws:


syntaxMatchesVariable

Determines whether the passed string represents a valid (PHP) variable.

private syntaxMatchesVariable(mixed $string): bool

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

public processText(string $text): string

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.

public getTagCompiler(string $tag): bool|\Smarty_Internal_CompileBase

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

public getPlugin(mixed $plugin_name, string $plugin_type): string

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

public getPluginFromDefaultHandler(string $tag, string $plugin_type): bool

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

public appendCode(string $left, string $right): string

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.

public processNocacheCode(string $content, bool $is_code): string

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

public getId(string $input): bool|string

Parameters:

Parameter Type Description
$input string

getVariableName

Get variable name from string

public getVariableName(string $input): bool|string

Parameters:

Parameter Type Description
$input string

setNocacheInVariable

Set nocache flag in variable or create new variable

public setNocacheInVariable(string $varName): mixed

Parameters:

Parameter Type Description
$varName string

convertScope

public convertScope(array $_attr, array $validScopes): int|string

Parameters:

Parameter Type Description
$_attr array tag attributes
$validScopes array

Throws:


makeNocacheCode

Generate nocache code string

public makeNocacheCode(string $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

public getVarExport(mixed $value): string

Parameters:

Parameter Type Description
$value mixed

enterDoubleQuote

enter double quoted string - save tag stack count

public enterDoubleQuote(): mixed

getTagStackCount

Return tag stack count

public getTagStackCount(): int

replaceDelimiter

public replaceDelimiter(mixed $lexerPreg): mixed

Parameters:

Parameter Type Description
$lexerPreg mixed

initDelimiterPreg

Build lexer regular expressions for left and right delimiter and user defined literals

public initDelimiterPreg(): mixed

leaveDoubleQuote

leave double quoted string - throw exception if block in string was not closed

public leaveDoubleQuote(): mixed

Throws:


getLdelPreg

Get left delimiter preg

public getLdelPreg(): string

getRdelPreg

Get right delimiter preg

public getRdelPreg(): string

getLdelLength

Get length of left delimiter

public getLdelLength(): int

getRdelLength

Get length of right delimiter

public getRdelLength(): int

getOpenBlockTag

Get name of current open block tag

public getOpenBlockTag(): string|bool

isVariable

Check if $value contains variable elements

public isVariable(mixed $value): bool|int

Parameters:

Parameter Type Description
$value mixed

getNewPrefixVariable

Get new prefix variable name

public getNewPrefixVariable(): string

getPrefixVariable

Get current prefix variable name

public getPrefixVariable(): string

appendPrefixCode

append code to prefix buffer

public appendPrefixCode(string $code): mixed

Parameters:

Parameter Type Description
$code string

getPrefixCode

get prefix code string

public getPrefixCode(): string

saveRequiredPlugins

Save current required plugins

public saveRequiredPlugins(bool $init = false): mixed

Parameters:

Parameter Type Description
$init bool if true init required plugins

restoreRequiredPlugins

Restore required plugins

public restoreRequiredPlugins(): mixed

compileRequiredPlugins

Compile code to call Smarty_Internal_Template::_checkPlugins() for required plugins

public compileRequiredPlugins(): string

compileCheckPlugins

Compile code to call Smarty_Internal_Template::_checkPlugins - checks if plugin is callable require otherwise

public compileCheckPlugins(mixed $requiredPlugins): string

Parameters:

Parameter Type Description
$requiredPlugins mixed

doCompile

method to compile a Smarty template

protected doCompile(mixed $_content, bool $isTemplateSource = false): bool
  • 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

public cStyleComment(mixed $string): mixed

Parameters:

Parameter Type Description
$string mixed

compileTag2

Compile Tag

private compileTag2(string $tag, array $args, array $parameter): string

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