File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,25 @@ any related error message:
1717
1818 .. note ::
1919
20- The ``template_from_string `` function is not available by default. You
21- must add the ``\Twig\Extension\StringLoaderExtension `` extension explicitly when
22- creating your Twig environment::
20+ The ``template_from_string `` function is not available by default.
21+
22+ On Symfony projects, you need to load it in your ``services.yaml `` file:
23+
24+ .. code-block :: yaml
25+
26+ services :
27+ Twig\Extension\StringLoaderExtension :
28+
29+ or ``services.php `` file::
30+
31+ $services->set(\Twig\Extension\StringLoaderExtension::class);
32+
33+ Otherwise, add the extension explicitly on the Twig environment::
34+
35+ use Twig\Extension\StringLoaderExtension;
2336
2437 $twig = new \Twig\Environment(...);
25- $twig->addExtension(new \Twig\Extension\ StringLoaderExtension());
38+ $twig->addExtension(new StringLoaderExtension());
2639
2740.. note ::
2841
You can’t perform that action at this time.
0 commit comments