yiisoft / yii2-twig

Yii 2 Twig extension.
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
136 stars 61 forks source link

Update documentation to remove reference to relative twig paths #138

Open developedsoftware opened 1 year ago

developedsoftware commented 1 year ago

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 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!)

samdark commented 1 year ago

Yes, needs to be updated. Would appreciate a pull request.