Skip to content

[TwigComponent]: allow to configure template naming strategy #2136

Open
@richardhj

Description

@richardhj

You can configure the templates as follows:

# config/packages/twig_component.yaml
twig_component:
    anonymous_template_directory: 'components/'
    defaults:
        # Namespace & directory for components
        App\Twig\Components\: 'components/'

which translates to: all Components in the PHP namespace App\Twig\Components\ will have their templates located in 'components/', so App\Twig\Components\MyModal will become components/MyModal.html.twig.

As some frameworks prefer snake_case over PascalCase, I'd like to configure the naming strategy as follows:

# config/packages/twig_component.yaml
twig_component:
    anonymous_template_directory: 'components/'
    defaults:
        # Namespace & directory for components
        App\Twig\Components\:
          template_directory: 'components/'
          name_prefix: ''
          naming_strategy: 'snake_case'

so App\Twig\Components\MyModal will become components/my_modal.html.twig.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)StalledTwigComponent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions