Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Add Best Practice guideline for partials/include#8608
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
wouterj commentedNov 12, 2017
👍 I like it. /cc@javiereguiluz please share your thoughts on this as you're the best practices master :) |
javiereguiluz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I agree with this proposal! the leading underscore has been an unofficial best practice for more than 12 years (since symfony 1) so it's time to make it official!
If I may, I'd like to propose some minor rewordings to this proposal:
..best-practice:: Prefix the file name of partial templates with an underscore.You often want to reuse template code using the ``include()`` function to avoidredundant code. To better differentiate those partials in the filesystem, youshould prefix their file names with a single underscore (e.g. ``_footer.html.twig``).
Thanks!
weaverryan commentedNov 12, 2017
I like it! Thank you Timon! |
Uh oh!
There was an error while loading.Please reload this page.
Hi there,
I was wondering if there is no Best Practice guide for partials/includes. So I would recommend to use a single prefixed underscore to determine such partials easily like in the Symfony demo application:https://github.com/symfony/demo/tree/master/templates/blog
I saw often other solutions like
@SomeBundle:Partials/post_form.html.twig. But I like the approach from the Symfony demo application, so it should be a Best Practice guideline :)Regards,
Timon