Twig Components / Methods / file_relative
file_relative is a Twig filter to transform the given absolute file path into a new file path relative to
project’s root directory.
{{ '/var/www/blog/templates/admin/index.html.twig'|file_relative }}
{# if project root dir is '/var/www/blog/', it returns 'templates/admin/index.html.twig' #}If the given file path is out of the project directory, a null value will be returned.
Source: Twig
                    
                        
                            
                        
                        Edit this page on GitHub
                    
                                        
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.
                
            Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.