Skip to content

Kirby 4.1.2

Str::safeTemplate()

Replaces placeholders in string with values from the data array and escapes HTML in the results in {{ }} placeholders while leaving HTML special characters untouched in {< >} placeholders

Str::safeTemplate(?string $string = null, array $data = [ ], array $options = [ ]): string

Parameters

Name Type Default Description
$string string|null null The string with placeholders
$data array [ ] Associative array with placeholders as
keys and replacements as values.
Supports query syntax.
$options array [ ] An options array that contains:
- fallback: if a token does not have any matches
- callback: to be able to handle each matching result (escaping is applied after the callback)

Return type

string

Parent class

Kirby\Toolkit\Str