Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[TwigBundle] added support for Twig namespaced paths (Twig 1.10)#5660
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
In a template, you can now use native Twig template names, instead ofthe Symfony ones:Before (still works): {% extends "AcmeDemoBundle::layout.html.twig" %} {% include "AcmeDemoBundle:Foo:bar.html.twig" %}After: {% extends "@AcmeDemo/layout.html.twig" %} {% include "@AcmeDemo/Foo/bar.html.twig" %}Using native template names is also faster.The only drawback is that the new notation looks similar to the way welocate resources in Symfony, which would be@AcmeDemoBundle/Resources/views/Foo/bar.html.twig. We could have usedthe same notation, but it is rather verbose (and by the way, using thisnotation did not work anyway in templates).fabpot commentedOct 3, 2012
I forgot to mention why I'd like to include this change besides performance: this would allow to share templates between a project using the Symfony2 full-stack framework and any other project using Twig. |
henrikbjorn commentedOct 3, 2012
👍 Will the old notation be deprecated at some point? |
stof commentedOct 3, 2012
@fabpot does it still support overwriting templates ? |
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.
why removingBundle ? this is not consistent with the way the@ notation is done elsewhere
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 are not consistent anyway as we go toResources/views/ when using the location notation. So, it was done for three main reasons: trying to be as far as possible as the current notation to avoid confusion (or not), removing something that is, by convention, always present anyway, and more importantly trying to be more agnostic for when the templates are used outside of the full-stack framework.
Now, I'm open to any suggestion and if the majority think we need/can keep the bundle suffix, that would fine for me as well.
This PR was merged into the master branch.Commits-------5c809d8 [TwigBundle] added support for Twig namespaced paths (Twig 1.10)Discussion----------[TwigBundle] added support for Twig namespaced paths (Twig 1.10)In a template, you can now use native Twig template names, instead ofthe Symfony ones:Before (still works): {% extends "AcmeDemoBundle::layout.html.twig" %} {% include "AcmeDemoBundle:Foo:bar.html.twig" %}After: {% extends "@AcmeDemo/layout.html.twig" %} {% include "@AcmeDemo/Foo/bar.html.twig" %}Using native template names is also faster.The only drawback is that the new notation looks similar to the way welocate resources in Symfony, which would be`@AcmeDemoBundle/Resources/views/Foo/bar.html.twig`. We could have usedthe same notation, but it is rather verbose (and by the way, using thisnotation did not work anyway in templates).TODO: update documentation---------------------------------------------------------------------------by fabpot at 2012-10-03T13:36:56ZI forgot to mention why I'd like to include this change besides performance: this would allow to share templates between a project using the Symfony2 full-stack framework and any other project using Twig.---------------------------------------------------------------------------by henrikbjorn at 2012-10-03T13:50:48Z:+1: Will the old notation be deprecated at some point?---------------------------------------------------------------------------by stof at 2012-10-03T14:29:50Z@fabpot does it still support overwriting templates ?
webmozart commentedApr 23, 2013
What's the reason for not also supporting this syntax in other parts of the framework, such as the controller? return$this->renderView('@AcmeDemo/Foo/bar.html.twig',array(...)); |
webmozart commentedApr 23, 2013
ref#6919 |
In a template, you can now use native Twig template names, instead of
the Symfony ones:
Before (still works):
After:
Using native template names is also faster.
The only drawback is that the new notation looks similar to the way we
locate resources in Symfony, which would be
@AcmeDemoBundle/Resources/views/Foo/bar.html.twig. We could have usedthe same notation, but it is rather verbose (and by the way, using this
notation did not work anyway in templates).
TODO: update documentation