SMARTY_VERSION
SMARTY_VERSION
The current version string for the current version of Brainy.
$default_assign_scope : integer
Sets the default assignment location for a variable. By default, variables are assigned to the local scope. In some contexts, it may be desirable for variable assignment to take place in the global scope.
By setting this property, the default scope can be set. This affects the following:
assign()
method on any TemplateData instance{assign}
function{capture}
function (it uses assign()
){include}
function when assign=""
is used$assignment_compat : integer
SmartyBC's usage will--by default--use Smarty 2's semantics for varaible assignment. This means that if a variable is already defined, a clone of the existing variable will be made to preserve references.
If this value is changed to Brainy::ASSIGN_NO_COMPAT
, Smarty 3's
assignment semantics will always be used regardless of whether SmartyBC
is used or not.
This is considered at compile time and not at runtime.
$compile_check : boolean|integer
When `true` or `Brainy::COMPILECHECK_ON`, templates are checked for changes. If changes exist, the template will be recompiled regardless of whether it has been compiled or cached. Disabling this in production may yield performance improvements if templates do not change.
$use_sub_dirs : boolean
When true, subdirectories will be created within compile directory.
This is useful for applications with very large numbers of templates, as it minimizes the number of files in each of the directories. This does not work when PHP's safe_mode is set to on.
$security_policy : \Box\Brainy\Templates\Security
The Security instance to use as a security policy.
assign(array|string $var, mixed|null|void $value = null, integer|void $scope = -1) : \Box\Brainy\Templates\TemplateData
Assigns $value to the variable in $var. If an associative array is passed as the only parameter, it is a mapping of variables to assign to the values to assign to them.
array|string | $var | the template variable name(s) |
mixed|null|void | $value | the value to assign |
integer|void | $scope | the scope to associate with the Smarty_Variable instance |
current TemplateData (or Smarty or Template) instance for chaining
assignGlobal(string $varname, mixed $value = null) : \Box\Brainy\Templates\TemplateData
Assigns a global Smarty variable to the global scope.
string | $varname | the global variable name |
mixed | $value | the value to assign |
current TemplateData (or Smarty or Template) instance for chaining
getTemplateVars(string $varname = null, \Box\Brainy\Templates\TemplateData $ptr = null, boolean $search_parents = true) : string|array
Returns a single or all assigned template variables
string | $varname | Name of variable to process, or null to return all |
\Box\Brainy\Templates\TemplateData | $ptr | Optional reference to data object |
boolean | $search_parents | Whether to include results from parent scopes |
variable value or or array of variables
clearAssign(string|array<mixed,string> $varName) : \Box\Brainy\Templates\TemplateData
Clear the given assigned template variable.
string|array<mixed,string> | $varName | The template variable(s) to clear |
current TemplateData (or Smarty or Template) instance for chaining
clearAllAssign() : \Box\Brainy\Templates\TemplateData
Clear all the assigned template variables.
current TemplateData instance for chaining
getVariable(string $variable, \Box\Brainy\Templates\TemplateData|null $_ptr = null, boolean $search_parents = true, boolean $error_enable = true) : mixed
Return the contents of an assigned variable.
string | $variable | the name of the Smarty variable |
\Box\Brainy\Templates\TemplateData|null | $_ptr | Optional reference to the data object |
boolean | $search_parents | Whether to search in the parent scope |
boolean | $error_enable | Whether to raise an error when the variable is not found. |
The contents of the variable.
cloneDataFrom(\Box\Brainy\Templates\TemplateData $source, boolean|void $override = true) : void
Copies each variable from the source into this object, creating new `Variable` objects along the way.
\Box\Brainy\Templates\TemplateData | $source | |
boolean|void | $override | Whether to override existing values |
enableSecurity(\Box\Brainy\Templates\Security|null|void $security_class = null) : \Box\Brainy\Brainy
Loads security class and enables security
\Box\Brainy\Templates\Security|null|void | $security_class |
when an invalid class is provided
The current Smarty instance for chaining
setTemplateDir(string|array<mixed,string> $template_dir) : \Box\Brainy\Brainy
Set template directory
string|array<mixed,string> | $template_dir | directory(s) of template sources |
The current Smarty instance for chaining
addTemplateDir(string|array $template_dir, string|null $key = null) : \Box\Brainy\Brainy
Add a directory to the list of directories where templates are stored
string|array | $template_dir | directory(s) of template sources |
string|null | $key | of the array element to assign the template dir to |
when the given template directory is not valid
The current Smarty instance for chaining
setPluginsDir(string|array $plugins_dir) : \Box\Brainy\Brainy
Set plugins directory
string|array | $plugins_dir | directory(s) of plugins |
current Smarty instance for chaining
addPluginsDir(string|array $plugins_dir) : \Box\Brainy\Brainy
Add a directory to the list of directories where plugins are stored
string|array | $plugins_dir | plugins folder |
current Smarty instance for chaining
setCompileDir(string $compile_dir) : \Box\Brainy\Brainy
Set compile directory
string | $compile_dir | directory to store compiled templates in |
current Smarty instance for chaining
setDefaultModifiers(array|string $modifiers) : \Box\Brainy\Brainy
Set default modifiers
array|string | $modifiers | modifier or list of modifiers to set |
current Smarty instance for chaining
addDefaultModifiers(array|string $modifiers) : \Box\Brainy\Brainy
Add default modifiers
array|string | $modifiers | modifier or list of modifiers to add |
current Smarty instance for chaining
createTemplate(string $template, mixed|void $compile_id = null, object|null|void $parent = null) : \Box\Brainy\Template
Creates a template object.
This creates a template object which later can be rendered by the Brainy::display() or Brainy::fetch() method.
string | $template | the resource handle of the template file |
mixed|void | $compile_id | compile id to be used with this template |
object|null|void | $parent | Parent scope to assign to the template |
compileAllTemplates(string $extension = '.tpl', boolean $force_compile = false, integer $time_limit, integer $max_errors = null) : integer
Compile all template files
string | $extension | Optional file extension |
boolean | $force_compile | Optional boolean that compiles all files instead of modified files |
integer | $time_limit | Optional integer to specify a runtime limit in seconds for the compilation process |
integer | $max_errors | Optional integer to set an error limit. If more errors occur, the function will abort |
number of template files recompiled
clearCompiledTemplate(string|null $resource_name = null, string|null $compile_id = null, integer|null $exp_time = null) : integer
Delete a compiled template file.
This clears the compiled version of the specified template resource, or all compiled template files if one is not specified. If you pass a $compile_id only the compiled template for this specific $compile_id is cleared. If you pass an $exp_time, then only compiled templates older than $exp_time seconds are cleared, by default all compiled templates are cleared regardless of their age. This function is for advanced use only, not normally needed.
string|null | $resource_name | template name |
string|null | $compile_id | compile id |
integer|null | $exp_time | expiration time |
number of template files deleted
registerPlugin(string $type, string $tag, callable $callback) : \Box\Brainy\Brainy
Registers plugin to be used in templates
string | $type | plugin type |
string | $tag | name of template tag |
callable | $callback | PHP callback to register |
when the plugin tag is invalid
Self-reference to facilitate chaining
unregisterPlugin(string $type, string $tag) : \Box\Brainy\Brainy
Unregister Plugin
string | $type | of plugin |
string | $tag | name of plugin |
Self-reference to facilitate chaining
registerResource(string $type, \Box\Brainy\Resources\Resource|array<mixed,\Box\Brainy\Resources\Resource> $callback) : \Box\Brainy\Brainy
Registers a resource to fetch a template
string | $type | name of resource type |
\Box\Brainy\Resources\Resource|array<mixed,\Box\Brainy\Resources\Resource> | $callback | Instance of \Box\Brainy\Resources\Resource, or array of callbacks to handle resource (deprecated) |
Self-reference to facilitate chaining
unregisterResource(string $type) : \Box\Brainy\Brainy
Unregisters a resource
string | $type | name of resource type |
Self-reference to facilitate chaining