Skip to content

[TwigComponent] Change component naming standard + optional name #786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

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