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
Direct Users
Properties summary
-
$_templater
protectedStringTemplate 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. -
templates() public
Gets/sets templates to use.
Method Detail
formatTemplate() public ¶
formatTemplate( string $name , array $data )
Formats a template string with $data
Parameters
- string $name
- The template name.
- array $data
- The data to insert.
Returns
string
getTemplates() public ¶
getTemplates( string|null $template null )
Gets templates to use or a specific template.
Parameters
- string|null $template optional null
- String for reading a specific template, null for all.
Returns
string|array
setTemplates() public ¶
setTemplates( array $templates )
Sets templates to use.
Parameters
- array $templates
- Templates to be added.
Returns
$this
templates() public ¶
templates( string|null|array $templates null )
Gets/sets templates to use.
Deprecated
3.4.0 Use setTemplates()/getTemplates() instead.
Parameters
- string|null|array $templates optional null
null or string allow reading templates. An array allows templates to be added.
Returns
$this|string|array