Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] Made TemplateNameParser able to parse templates in the @-notation (#5660)#7818
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
stof commentedApr 23, 2013
@bschussek I see an issue here: as you are parsing the |
webmozart commentedApr 23, 2013
@stof Yes, you're right. We have to replace the bundle check by a namespace check. But we can only do this if we also register the namespaces in the Templating component (apart from Twig). |
stof commentedApr 23, 2013
@bschussek currently, the TwigBundle FilesystemLoader is using the parser and then fallback to using the string itself as template name directly. This works well and does not break the Twig features. All we need is allowing the TwigEngine to work this way too instead of forcing to have a bundle notation IMO. |
webmozart commentedApr 23, 2013
stof commentedApr 23, 2013
If I register a namespace path |
beberlei commentedApr 30, 2013
Regarding the Bundle suffix, we tried this in early alpha some time i remember and then unilaterally wanted to move back to the Bundle suffix one alpha later. |
webmozart commentedApr 30, 2013
@beberlei I'm slow today, what's your point? :) Are you saying we should bring back the "Bundle" suffix here as well? |
beberlei commentedApr 30, 2013
@bschussek Bring back? The todo says you are evaluating to remove it here, did you already? |
webmozart commentedApr 30, 2013
Oh, this is badly named then :) The Bundle suffix is already dropped for this notation. The questions is whether we bring it back in 2.3 (now that the syntax is not that wide-spread yet) or to leave this inconsistency in at least until 3.0. Ping@fabpot |
webmozart commentedJun 15, 2013
A very interesting proposal came up in the FIG that could solve the problems mentioned here in a much more generic scope: https://groups.google.com/forum/?fromgroups#!topic/php-fig/WMaKNNhHZJw |
ahilles107 commentedSep 2, 2013
👍 for this PR, in Sourcefabric we wait for that, tell if we can help! |
webmozart commentedMar 11, 2014
Closing this. The same functionality - but better - will be delivered bywebmozart/symfony-puli-bundle at some point. |
This PR adds the ability to handle Twig's new template name syntax (see fabpot/Twig#772 and#5660) to the
TemplateNameParserclass. Before, the syntax could only be used in Twig's own functionality, such as theextendorincludestatements. Now, the syntax can be used anywhere in a Symfony application, such as when returning from a Controller, the@Templateannotation or with PHP Templating. The old syntax "bundle:controller:template" is still supported, but can be completely replaced*.Examples:
index.html.twig::index.html.twigFoo/bar.html.php:Foo:bar.html.php@AcmeDemo/test.html.twigAcmeDemoBundle::test.html.twig@AcmeDemo/Post/create.html.phpAcmeDemoBundle:Post:create.html.php* The support for bundle inheritance is still missing for Twig:#6918
Benchmarks
Performance benchmark:
Scripts:
benchmark-old.php
benchmark-new.php
benchmark-new2.php
Remaining Concerns
My remaining concern is about the convention to drop the bundle suffix in the new syntax. I dislike it for three reasons:
@AcmeDemo/index.html.twigvs.@AcmeDemoBundle/Resources/config/routing.yml)@AcmeDemo/index.html.twigvs.AcmeDemoBundle/index.html.twig)@Monolog/template.html.twigbut for the second as well, creating a conflict)@fabpot stated in#5660 that an advantage of dropping the "Bundle" suffix is making the namespaces
I disagree. When I load MonologBundle into my non-Symfony application, it makes sense that the namespace is "MonologBundle".
The second question we have to solve is whether we change the logical template name (
TemplateReference::getLogicalName()) to the new syntax as well. I left it at the old syntax for now because I don't know what the BC implications would be.