Skip to content

Commit be33323

Browse files
committed
Merge branch '2.x' into 3.x
* 2.x: Fix doc CS Adding installation instructions for Symfony
2 parents 40b6f59 + 9170edf commit be33323

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

doc/functions/template_from_string.rst

+17-4
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)