Skip to content

Kirby 3.6.6


Replaces placeholders in string with values from the data array

Deprecated in 3.6.0
The parameters $fallback, $start and $end have been deprecated and throw a deprecation warning. Use instead an $options array with fallback, start and/or end keys as third parameter.
Str::template(string $string = null, array $data = [ ], string|array|null $fallback = null, string $start = '{{', string $end = '}}'): string


Name Type Default Description
$string string null The string with placeholders
$data array [ ] Associative array with placeholders as
keys and replacements as values.
Supports query syntax.
$fallback string|array|null null An options array that contains:
- fallback: if a token does not have any matches
- callback: to be able to handle each matching result
- start: start placeholder
- end: end placeholder
A simple fallback string is supported for compatibility (but deprecated).
$start string '{{' Placeholder start characters (deprecated)
$end string '}}' Placeholder end characters (deprecated)

Return type


Parent class