Skip to content

Conversation

@weaverryan
Copy link
Member

@weaverryan weaverryan commented Apr 13, 2023

Q A
Bug fix? no
New feature? yes
Tickets None
License MIT

Changes the naming convention of components to upper camel case + makes the name argument optional (defaults to class name). Components now look like:

    #[AsTwigComponent]
    class Alert
    {
        public string $type = 'success';
        public string $message;
    }

The template is templates/components/Alert.html.twig and you render with {{ component('Alert') }}. This removes the need for the user to invent & keep track of an arbitrary name, but they can still pass a name to AsTwigComponent. No BC break on this.

Relates to a conversation on #771 (comment)

TODO:

  • Update MakerBundle to follow this convention

@WebMamba
Copy link
Contributor

I actually always follow this convention. This felt way more natural to have the same name on the PHP files and on the views side. So 100% agree here.

@weaverryan weaverryan force-pushed the twig-components-change-naming-standard branch from c81bc6e to 8dc9a7d Compare April 14, 2023 13:40
@weaverryan weaverryan merged commit b24c1a3 into symfony:2.x Apr 14, 2023
@weaverryan weaverryan deleted the twig-components-change-naming-standard branch April 14, 2023 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants