From 5280bbf80a5873105a7ff65b22444f5e8b37edab Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 22 Sep 2022 00:58:09 +0200 Subject: [PATCH] Adding installation instructions for Symfony Wording is taken from https://twig.symfony.com/doc/3.x/filters/format_datetime.html --- doc/functions/template_from_string.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/functions/template_from_string.rst b/doc/functions/template_from_string.rst index 80e9d2dede..90ce78bd70 100644 --- a/doc/functions/template_from_string.rst +++ b/doc/functions/template_from_string.rst @@ -17,9 +17,18 @@ any related error message: .. note:: - The ``template_from_string`` function is not available by default. You - must add the ``\Twig\Extension\StringLoaderExtension`` extension explicitly when - creating your Twig environment:: + The ``template_from_string`` function is not available by default. + + In Symfony projects, you need to load it in your ``services.yaml``:: + + services: + Twig\Extension\StringLoaderExtension: + + or ``services.php``:: + + $services->set(\Twig\Extension\StringLoaderExtension::class); + + Otherwise, add the extension explicitly on the Twig environment:: $twig = new \Twig\Environment(...); $twig->addExtension(new \Twig\Extension\StringLoaderExtension());