Edit on GitHub
Jump to docs navigation

Twig Components / Methods / file_relative

Note: You are currently reading the documentation for Bolt 5.0. Looking for the documentation for Bolt 5.2 instead?

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.