-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBundle] Add default templates directory and option to configure it #24179
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
src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
Outdated
Show resolved
Hide resolved
Please no overrides dir. just keep it inside a bundles dir. Does it really matter. The one working on code knows. |
Changed to |
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.
We should have a test case for this.
src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
80a66f7
to
c8e1327
Compare
Tests added. |
Just a question; should we deprecate the old paths (hardcoded in src). Ie trigger in case of Only if not configured as path already of course. |
Thank you @yceruto. |
…n to configure it (yceruto) This PR was merged into the 3.4 branch. Discussion ---------- [TwigBundle] Add default templates directory and option to configure it | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Feature freeze is coming so this one should be important for the new structure. Moving forward and alternative of #23339 but I'm proposing `templates/bundles/<BundleName>` instead of `templates/bundles/<BundleTwigNamespace>` to override bundles templates and easy migration from current `app/Resources/<BundleName>/views` convention. Also this fix the pending comments. Summary: * Added new option to configure default path for templates directory: ```yaml twig: default_path: '%kernel.project_dir%/templates' # default ``` * Added new path convention to override bundle templates `<default_path>/bundles/<BundleName>`: ``` # Examples: templates/bundles/TwigBundle/Exception/error.html.twig - @Twig/Exception/error.html.twig templates/bundles/FOSUserBundle/layout.html.twig - @FOSUser/layout.html.twig ``` Current templates in `<kernel.root_dir>/Resources/<BundleName>/views` have priority over the new one, and both have priority over the bundle `views` path. Commits ------- a1b391f Add default templates directory and option to configure it
Just tested on 2 of my projects, and it works perfectly. |
I agree with @ro0NL that we should deprecate the old
|
@Tobion at time of posting i didnt realize we need to support both variants; legacy and new projects. I think also related is we dont want to force users switching to a new structure for no real benefit. But the fact you can mix&match can be confusing for sure! So yes, i think the current approach is a bit too pragmatic. Technically we're fine :) |
This PR was merged into the 3.4 branch. Discussion ---------- Add default_path option reference symfony/symfony#24179 Commits ------- 66fd357 Minor tweaks af245fc Add default_path option reference
Can anyone tell me if this was tested / supposed to work with Form templates? Doesn't seem to be working. Specifically templates in |
@nesl247 please open a new issue if you think you discovered a bug |
Will do. Wasn't sure if I should or not as I'm not sure if it's working as intended or a bug. |
Hi @yceruto, Asking, because we have more than 2k templates references, and renaming could cause new bugs, but maintaining two folders for override templates at the same time is confusing for developers. |
That's correct.
Since 4.2 |
Feature freeze is coming so this one should be important for the new structure. Moving forward and alternative of #23339 but I'm proposing
templates/bundles/<BundleName>
instead oftemplates/bundles/<BundleTwigNamespace>
to override bundles templates and easy migration from currentapp/Resources/<BundleName>/views
convention. Also this fix the pending comments.Summary:
<default_path>/bundles/<BundleName>
:Current templates in
<kernel.root_dir>/Resources/<BundleName>/views
have priority over the new one, and both have priority over the bundleviews
path.