public static function TwigTweakExtension::tokenReplaceFilter in Twig Tweak 3.x
Same name and namespace in other branches
- 3.1.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::tokenReplaceFilter()
Replaces all tokens in a given string with appropriate values.
Parameters
string $text: An HTML string containing replaceable tokens.
array $data: (optional) An array of keyed objects. For simple replacement scenarios 'node', 'user', and others are common keys, with an accompanying node or user object being the value. Some token types, like 'site', do not require any explicit information from $data and can be replaced even if it is empty.
array $options: (optional) A keyed array of settings and flags to control the token replacement process.
Return value
string The entered HTML text with tokens replaced.
File
- src/
TwigTweakExtension.php, line 450
Class
- TwigTweakExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public static function tokenReplaceFilter(string $text, array $data = [], array $options = []) : string {
return \Drupal::token()
->replace($text, $data, $options);
}