Skip to content

Using the new template naming in the documentation #3849

Closed
@javiereguiluz

Description

@javiereguiluz

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 the traditional syntax, you have four different formats to explain:

::template1.twig
AcmeDemoBundle::template2.twig
AcmeDemoBundle:Default:template3.twig
AcmeDemoBundle:Default:common/template4.twig

Using the new namespaced syntax everything is straightforward:

template1.twig
@AcmeDemoBundle/template2.twig
@AcmeDemoBundle/Default/template3.twig
@AcmeDemoBundle/Default/common/template4.twig

With the new syntax you only have to write the path from Resources/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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions