Skip to content

Commit fab3e0f

Browse files
committed
minor #3744 Adding installation instructions for Symfony (ThomasLandauer)
This PR was submitted for the 3.x branch but it was merged into the 2.x branch instead. Discussion ---------- Adding installation instructions for Symfony Wording is taken from https://twig.symfony.com/doc/3.x/filters/format_datetime.html Commits ------- c034c1d Adding installation instructions for Symfony
2 parents 226b73c + c034c1d commit fab3e0f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

doc/functions/template_from_string.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ any related error message:
2121
2222
.. note::
2323

24-
The ``template_from_string`` function is not available by default. You
25-
must add the ``\Twig\Extension\StringLoaderExtension`` extension explicitly when
26-
creating your Twig environment::
24+
The ``template_from_string`` function is not available by default.
25+
26+
In Symfony projects, you need to load it in your ``services.yaml``::
27+
28+
services:
29+
Twig\Extension\StringLoaderExtension:
30+
31+
or ``services.php``::
32+
33+
$services->set(\Twig\Extension\StringLoaderExtension::class);
34+
35+
Otherwise, add the extension explicitly on the Twig environment::
2736

2837
$twig = new \Twig\Environment(...);
2938
$twig->addExtension(new \Twig\Extension\StringLoaderExtension());

0 commit comments

Comments
 (0)