Skip to content

Commit b24c1a3

Browse files
committed
feature #786 [TwigComponent] Change component naming standard + optional name (weaverryan)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [TwigComponent] Change component naming standard + optional name | 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: ```php #[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 Commits ------- 8dc9a7d [TwigComponent] Change component naming standard + optional name
2 parents 8eb4e08 + 8dc9a7d commit b24c1a3

File tree

65 files changed

+353
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+353
-311
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 99 additions & 101 deletions
Large diffs are not rendered by default.

src/LiveComponent/src/Attribute/AsLiveComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
final class AsLiveComponent extends AsTwigComponent
2323
{
2424
public function __construct(
25-
string $name,
25+
?string $name = null,
2626
?string $template = null,
2727
private ?string $defaultAction = null,
2828
bool $exposePublicProps = true,

src/TwigComponent/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- `true` attribute values now render just the attribute name, `false` excludes it entirely.
66

7+
- The first argument to `AsTwigComponent` is now optional and defaults to the class name.
8+
79
## 2.7.0
810

911
- `PreMount` and `PostMount` hooks can now return nothing.

0 commit comments

Comments
 (0)