-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Example to include templates doesn't work #5318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The PHP example for including templates within templates doesn't work. Without the colons, the engine looks for `article_details.html.php` in `app\Resources\` instead 8000 of `app\Resources\views\article`
Honestly, I think the example should be re-written as something like |
@jxmallett thanks for opening this issue to improve the Symfony docs. In Symfony, there are three main ways to refer to a template:
These three syntaxes work right and you can even mix all of them in the same application (obviously this is not recommended). However, in the documentation we decided a few months ago to use the simple syntax and forget about the dotted syntax used traditionally in the Symfony world. The simple syntax complies with the Symfony Best Practices and we reserve the dotted syntax just for third-party bundles. |
Thanks for the info, @javiereguiluz. I was getting a little confused seeing the different syntax. Also interesting to know that Symfony Best Practices recommends putting all application templates in I still think there's an issue though, and it's possibly a bug in Symfony itself. The templating and Best Practice docs say that I should, for example, put my template in Firstly, there's a difference in the capitalization of My real issue is that the simple name |
Regarding the capitalization, you are right. We should replace Regarding the location of the templates, it's correct that they are stored in |
@jxmallett So, if I do understand you correctly, this is only an issue when using the PHP templating engine? When using Twig placing the files under |
I think you're right that this is a bug in the PHP templating engine, @xabbuh - I tried this in a Twig template and it worked fine. To reproduce: |
As a side note, it would be really nice if the 'not found' error message included a list of locations it checked. So instead of saying Certainly beyond the scope of this thread, and it looks like it would require non-trivial source code changes, but it would have saved me a lot of debug time! |
@jxmallett this should be requested to the Twig project |
@jxmallett I really like the idea of displaying all the template paths tested before failing. |
A possible change to the PHP templating engine should be discussed on the symfony/symfony repository. |
I created 2 issues for the bugs and ideas suggested in this topic: symfony/symfony#14806 and symfony/symfony#14804 I'm going to close this topic, as the bug should be fixed in the code instead of adopting the docs to the bug. Thanks for bringing up these things, @jxmallett! |
Thanks for your help @wouterj |
The PHP example for including templates within templates doesn't work.
Without the colons, the engine looks for
article_details.html.php
inapp\Resources\
instead ofapp\Resources\views\article