We have been trying to use relative paths in twig files as per the documentation below. Only to find out that twig does not actually support relative paths in twig files.
In the first case the view will be searched relatively to the current template path. For comment.twig and post.twig that means these will be searched in the same directory as the currently rendered template.
Whilst I assume the above means, in the same path of the "first" rendered template (because that actually works). If you in root_folder/A.twig include a twig file (some_relative_folder/B.twig), and inside that twig file include another twig file (C.twig) you would expect it to look in some_relative_folder, but it only looks in root_folder and then errors saying it cannot find C.twig.
Should the documentation be updated to make that more clear? It defo tripped us up (we are not using aliases everywhere!)
As mentioned here https://github.com/twigphp/Twig/issues/3730#issuecomment-1198991950
And also referencing issue #137
We have been trying to use relative paths in twig files as per the documentation below. Only to find out that twig does not actually support relative paths in twig files.
https://www.yiiframework.com/extension/yiisoft/yii2-twig/doc/guide/2.3/en/template-syntax#referencing-other-templates
In the first case the view will be searched relatively to the current template path. For comment.twig and post.twig that means these will be searched in the same directory as the currently rendered template.
Whilst I assume the above means, in the same path of the "first" rendered template (because that actually works). If you in
root_folder/A.twig
include a twig file (some_relative_folder/B.twig
), and inside that twig file include another twig file (C.twig
) you would expect it to look insome_relative_folder
, but it only looks inroot_folder
and then errors saying it cannot findC.twig
.Should the documentation be updated to make that more clear? It defo tripped us up (we are not using aliases everywhere!)