Skip to content

[TwigBundle] Allow changing bundle overrides root directory #23445

Closed
@Pierstoval

Description

@Pierstoval
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 3 & 4

There's a small discussion in symfony/flex#40 and some other on Twitter about the fact that when using Flex, to override a bundle template one has to put it in src/Resources/{BundleName}/views/.

This is something that is a bit counter-intuitive when Flex recommends putting all templates in the templates/ directory.

My proposal is to add a new parameter to Twig's configuration:

twig:
    # Default config, identical to current behavior
    bundle_overrides_dir: '%kernel.root_dir%/Resources/`

In terms of current behavior, not changing this value would keep BC, and for the rest, the path could be changed in Twig's Flex recipe for something like this:

twig:
    # Flex config
    bundle_overrides_dir: '%kernel.project_dir%/templates/`

Then, to override a bundle directory, one would just have to create it in templates/{BundleName}/views/.

The only point I'm not totally comfortable with is the fact that views/ is always appended to the directory, and therefore makes it a bit redundant to have both templates and views in the same path.
Not sure about what to do in this case 🤔

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions