File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -637,6 +637,27 @@ file_link
637637Generates a link to the provided file and line number using
638638a preconfigured scheme.
639639
640+ file_relative
641+ ~~~~~~~~~~~~~
642+
643+ .. code-block :: twig
644+
645+ {{ file|file_relative }}
646+
647+ ``file ``
648+ **type **: ``string ``
649+
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/ ``.
652+
653+ .. code-block :: twig
654+
655+ {{ '/var/www/blog/templates/admin/index.html.twig'|file_relative }}
656+ {# templates/admin/index.html.twig #}
657+
658+ If the passed path doesn't match the project directory, a ``null `` value
659+ will be returned.
660+
640661.. _reference-twig-tags :
641662
642663Tags
You can’t perform that action at this time.
0 commit comments