Properties

$template_resource

$template_resource : string

Template resource

Type

string

$strict_mode

$strict_mode : boolean

Flag indicating that the template is running in strict mode

Type

boolean

$smarty

$smarty : \Box\Brainy\Templates\Smarty

Global smarty instance

Type

\Box\Brainy\Templates\Smarty

Methods

assign()

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.

Parameters

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

Returns

\Box\Brainy\Templates\TemplateData

current TemplateData (or Smarty or Template) instance for chaining

assignGlobal()

assignGlobal(string  $varname, mixed  $value = null) : \Box\Brainy\Templates\TemplateData

Assigns a global Smarty variable to the global scope.

Parameters

string $varname

the global variable name

mixed $value

the value to assign

Returns

\Box\Brainy\Templates\TemplateData

current TemplateData (or Smarty or Template) instance for chaining

getTemplateVars()

getTemplateVars(string  $varname = null, \Box\Brainy\Templates\TemplateData  $ptr = null, boolean  $search_parents = true) : string|array

Returns a single or all assigned template variables

Parameters

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

Returns

string|array —

variable value or or array of variables

clearAssign()

clearAssign(string|array<mixed,string>  $varName) : \Box\Brainy\Templates\TemplateData

Clear the given assigned template variable.

Parameters

string|array<mixed,string> $varName

The template variable(s) to clear

Returns

\Box\Brainy\Templates\TemplateData

current TemplateData (or Smarty or Template) instance for chaining

clearAllAssign()

clearAllAssign() : \Box\Brainy\Templates\TemplateData

Clear all the assigned template variables.

Returns

\Box\Brainy\Templates\TemplateData

current TemplateData instance for chaining

getVariable()

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.

Parameters

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.

Returns

mixed —

The contents of the variable.

cloneDataFrom()

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.

Parameters

\Box\Brainy\Templates\TemplateData $source
boolean|void $override

Whether to override existing values

applyDataFrom()

applyDataFrom(array  $source, boolean|void  $override = true) : void

Applies all of the data to the current object

Parameters

array $source
boolean|void $override

Whether to override existing values

__construct()

__construct(\Box\Brainy\Brainy  $brainyInstance, boolean|void  $useRootScope = false) 

Parameters

\Box\Brainy\Brainy $brainyInstance
boolean|void $useRootScope

Whether to clone data from the root scope

assert_is_not_strict()

assert_is_not_strict(string  $reason) : void

Parameters

string $reason

Throws

\Box\Brainy\Exceptions\BrainyStrictModeException

fetch()

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.

Parameters

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

Returns

string —

rendered template output

display()

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.

Parameters

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

setVariable()

setVariable(string  $var, mixed  $value, integer  $scope = -1) : void

Assigns $value to the variale $var.

Parameters

string $var

the template variable name

mixed $value

the value to assign

integer $scope

the scope to associate with the Smarty_Variable

renderSubTemplate()

renderSubTemplate(string  $template, mixed  $compile_id,   $data, integer  $parent_scope) : void

Template code runtime function to get subtemplate content

Parameters

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

assignSingleVar()

assignSingleVar(string  $var, mixed  $value, integer  $scope = -1) : void

Assigns $value to the variale $var.

Parameters

string $var

the template variable name

mixed $value

the value to assign

integer $scope

the scope to associate with the Smarty_Variable