Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Description
The other day,@lyrixx and I were talking about Twig template naming and locations and he asked if we could update the official Symfony documentation to use the new template syntax.
Imagine that your project has the following four templates:
your-project/ ├─ app/ │ └─ Resources │ └─ views/ │ └─ template1.twig ├─ src/ │ └─ Acme/ │ └─ Bundle/ │ └─ DemoBundle/ │ └─ Resources │ └─ views/ │ ├─ template2.twig │ └─ Default/ │ ├─ template3.twig │ └─ common/ │ └─ template4.twig ├─ vendor/ └─ web/Using thetraditional syntax, you have four different formats to explain:
::template1.twigAcmeDemoBundle::template2.twigAcmeDemoBundle:Default:template3.twigAcmeDemoBundle:Default:common/template4.twigUsing thenew namespaced syntax everything is straightforward:
template1.twig@AcmeDemoBundle/template2.twig@AcmeDemoBundle/Default/template3.twig@AcmeDemoBundle/Default/common/template4.twigWith the new syntax you only have to write the path fromResources/views/, without thinking if the template is associated with a controller or if it's stored in a subdirectory. Everything is much easier to explain, specially for Symfony newcomers.
Forgetting for a moment about the colossal effort that would be needed to update all the documentation, what do you think about this proposal?