File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -640,22 +640,25 @@ a preconfigured scheme.
640640file_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
659662will be returned.
660663
661664.. _reference-twig-tags :
You can’t perform that action at this time.
0 commit comments