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.
640
640
file_relative
641
641
~~~~~~~~~~~~~
642
642
643
+ .. versionadded ::
644
+ The ``file_relative `` filter was introduced in Symfony 4.2.
645
+
643
646
.. code-block :: twig
644
647
645
648
{{ file|file_relative }}
646
649
647
650
``file ``
648
651
**type **: ``string ``
649
652
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:
652
655
653
656
.. code-block :: twig
654
657
655
658
{{ '/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' #}
657
660
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
659
662
will be returned.
660
663
661
664
.. _reference-twig-tags :
You can’t perform that action at this time.
0 commit comments