$template_resource
$template_resource : string
Full template resource
__construct(string $tplResource, \Box\Brainy\Brainy $brainy, \Box\Brainy\Templates\Template $parent = null, mixed $compileID = null, boolean|void $suppressData = false)
Create template data object
Some of the global Smarty settings copied to template scope It load the required template resources and cacher plugins
string | $tplResource | template resource string |
\Box\Brainy\Brainy | $brainy | Brainy instance |
\Box\Brainy\Templates\Template | $parent | back pointer to parent object with variables or null |
mixed | $compileID | compile id or null |
boolean|void | $suppressData | Prevents data from being copied into the variable scope |
fetch(string|void $template = null, mixed|void $compile_id = null) : string
Renders and returns a template.
This returns the template output instead of displaying it.
string|void | $template | the resource handle of the template file or template object |
mixed|void | $compile_id | compile id to be used with this template |
rendered template output
display(string|null|void $template = null, string|null|void $compile_id = null) : void
Renders the template.
This displays the contents of a template. To return the contents of a template into a variable, use the fetch() method instead.
As an optional second and third parameter, you can pass a cache ID and compile ID.
A fourth parameter can be passed which passes the parent scope that the template should use.
string|null|void | $template | the resource handle of the template file or template object |
string|null|void | $compile_id | compile id to be used with this template |
renderSubTemplate(string $template, mixed $compile_id, $data, integer $parent_scope) : void
Template code runtime function to get subtemplate content
string | $template | the resource handle of the template file |
mixed | $compile_id | compile id to be used with this template |
$data | ||
integer | $parent_scope | scope in which {include} should execute |
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 |