File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -22,20 +22,24 @@ any related error message:
22
22
.. note ::
23
23
24
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 ``::
25
+
26
+ On Symfony projects, you need to load it in your ``services.yaml `` file:
27
+
28
+ .. code-block :: yaml
27
29
28
30
services :
29
31
Twig\Extension\StringLoaderExtension :
30
32
31
- or ``services.php ``::
33
+ or ``services.php `` file ::
32
34
33
35
$services->set(\Twig\Extension\StringLoaderExtension::class);
34
-
36
+
35
37
Otherwise, add the extension explicitly on the Twig environment::
36
38
39
+ use Twig\Extension\StringLoaderExtension;
40
+
37
41
$twig = new \Twig\Environment(...);
38
- $twig->addExtension(new \Twig\Extension\ StringLoaderExtension());
42
+ $twig->addExtension(new StringLoaderExtension());
39
43
40
44
.. note ::
41
45
You can’t perform that action at this time.
0 commit comments