Skip to content

Commit

Permalink
Merge branch '2.x' into 3.x
Browse files Browse the repository at this point in the history
* 2.x:
  Fix doc CS
  Adding installation instructions for Symfony
  • Loading branch information
fabpot committed Sep 28, 2022
2 parents 40b6f59 + 9170edf commit be33323
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions doc/functions/template_from_string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,25 @@ 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.

On Symfony projects, you need to load it in your ``services.yaml`` file:

.. code-block:: yaml
services:
Twig\Extension\StringLoaderExtension:
or ``services.php`` file::

$services->set(\Twig\Extension\StringLoaderExtension::class);

Otherwise, add the extension explicitly on the Twig environment::

use Twig\Extension\StringLoaderExtension;

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

.. note::

Expand Down

0 comments on commit be33323

Please sign in to comment.