Skip to content

Commit 89ecae3

Browse files
committed
wip
1 parent 8f76853 commit 89ecae3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/view/src/ViewComponentDiscovery.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ public function discoverPath(DiscoveryLocation $location, string $path): void
4949

5050
preg_match('/(?<header>(.|\n)*?)<x-component name="(?<name>[\w\-]+)">/', $contents->toString(), $matches);
5151

52-
$view = $contents
53-
->replaceRegex('/^(.|\n)*?<x-component.*>/', '')
54-
->replaceRegex('/<\/x-component>$/', '')
55-
->toString();
52+
if (isset($matches['name'])) {
53+
$view = $contents
54+
->replaceRegex('/^(.|\n)*?<x-component.*>/', '')
55+
->replaceRegex('/<\/x-component>$/', '')
56+
->toString();
57+
} else {
58+
$view = $contents->toString();
59+
}
5660

57-
if ($fileName->startsWith('x-') && ! isset($matches['name'])) {
61+
if ($fileName->startsWith('x-')) {
5862
$this->discoveryItems->add($location, [
5963
$fileName->toString(),
6064
new AnonymousViewComponent(

0 commit comments

Comments
 (0)