Skip to content

Commit

Permalink
minor #3744 Adding installation instructions for Symfony (ThomasLanda…
Browse files Browse the repository at this point in the history
…uer)

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
  • Loading branch information
fabpot committed Sep 28, 2022
2 parents 226b73c + c034c1d commit fab3e0f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions doc/functions/template_from_string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@ 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.

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

services:
Twig\Extension\StringLoaderExtension:

or ``services.php``::

$services->set(\Twig\Extension\StringLoaderExtension::class);
Otherwise, add the extension explicitly on the Twig environment::

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

0 comments on commit fab3e0f

Please sign in to comment.