Trait StringTemplateTrait
Adds string template functionality to any class by providing methods to load and parse string templates.
This trait requires the implementing class to provide a config()
method for reading/updating templates. An implementation of this method
is provided by Cake\Core\InstanceConfigTrait
Namespace: Cake\View
Property Summary
-
$_templater protected
Cake\View\StringTemplate|null
StringTemplate instance.
Method Summary
-
formatTemplate() public
Formats a template string with $data
-
getTemplates() public
Gets templates to use or a specific template.
-
setTemplates() public
Sets templates to use.
-
templater() public
Returns the templater instance.
Method Detail
formatTemplate() ¶ public
formatTemplate(string $name, array<string, mixed> $data): string
Formats a template string with $data
Parameters
-
string
$name The template name.
-
array<string, mixed>
$data The data to insert.
Returns
string
getTemplates() ¶ public
getTemplates(string|null $template = null): array|string
Gets templates to use or a specific template.
Parameters
-
string|null
$template optional String for reading a specific template, null for all.
Returns
array|string
setTemplates() ¶ public
setTemplates(array<string, string> $templates): $this
Sets templates to use.
Parameters
-
array<string, string>
$templates Templates to be added.
Returns
$this
templater() ¶ public
templater(): Cake\View\StringTemplate
Returns the templater instance.
Returns
Cake\View\StringTemplate