On this page
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
Property Summary
-
$_templater protected
Cake\View\StringTemplate|nullStringTemplate 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
stringgetTemplates() 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|stringsetTemplates() public
setTemplates(array<string> $templates): $this
Sets templates to use.
Parameters
array<string>$templates-
Templates to be added.
Returns
$thistemplater() public
templater(): Cake\View\StringTemplate
Returns the templater instance.
Returns
Cake\View\StringTemplateProperty Detail
$_templater protected
StringTemplate instance.
Type
Cake\View\StringTemplate|null© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/trait-Cake.View.StringTemplateTrait.html