Skip to content

Commit 67460dc

Browse files
Reword and added the versionadded directive
1 parent 3eec2ce commit 67460dc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

reference/twig_reference.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,22 +640,25 @@ a preconfigured scheme.
640640
file_relative
641641
~~~~~~~~~~~~~
642642

643+
.. versionadded::
644+
The ``file_relative`` filter was introduced in Symfony 4.2.
645+
643646
.. code-block:: twig
644647
645648
{{ file|file_relative }}
646649
647650
``file``
648651
**type**: ``string``
649652

650-
Returns the relative path from the passed absolute file path. For example,
651-
assume you've a project in the following directory: ``/var/www/blog/``.
653+
It transforms the given absolute file path into a relative file path from the
654+
project's root directory:
652655

653656
.. code-block:: twig
654657
655658
{{ '/var/www/blog/templates/admin/index.html.twig'|file_relative }}
656-
{# templates/admin/index.html.twig #}
659+
{# if project root dir is '/var/www/blog/', it returns 'templates/admin/index.html.twig' #}
657660
658-
If the passed path doesn't match the project directory, a ``null`` value
661+
If the given file path is out of the project directory, a ``null`` value
659662
will be returned.
660663

661664
.. _reference-twig-tags:

0 commit comments

Comments
 (0)