Whitelisted Functions
use Centum\Twig\WhitelistedFunctionsExtension;
use Twig\Environment;
/** @var Environment $twig */
$twig->addExtension(
new WhitelistedFunctionsExtension(
[
"ucfirst",
"lcfirst",
"number_format",
// ...
]
)
);
Within your Twig files, you can now use these functions:
{{ ucfirst('the first letter will be capitalised.') }}
For bonus points, set your whitelisted functions in a config file. ;)