From 8c88b9d94a3eed9ceb8c5ff135a64a9f9858ae60 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Thu, 25 Jun 2026 14:56:39 -0400 Subject: [PATCH] allow props which values contains spaces and numbers --- flight/template/View.php | 4 ++-- tests/ViewTest.php | 7 +++++++ ...t-with-prop-which-value-contains-spaces-and-numbers.php | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/views/pages/page-with-component-with-prop-which-value-contains-spaces-and-numbers.php diff --git a/flight/template/View.php b/flight/template/View.php index e3f8993..10a55b2 100644 --- a/flight/template/View.php +++ b/flight/template/View.php @@ -173,7 +173,7 @@ class View } preg_match_all( - "/<$this->componentPrefix-(?[a-z-]+)\s*(?([a-z]+=\"[a-zA-Z]+\"\s*)*)?\s*\/>/", + "/<$this->componentPrefix-(?[a-z-]+)\s*(?([a-z]+=\"[^\"]+\"\s*)*)?\s*\/>/", $view, $tagsMatches, ); @@ -186,7 +186,7 @@ class View $props = $tagsMatches['props'][$tagIndex] ?? ''; preg_match_all( - '/(?[a-z]+)="(?[a-zA-Z]+)"/', + '/(?[a-z]+)="(?[^"]+)"/', $props, $propsMatches, ); diff --git a/tests/ViewTest.php b/tests/ViewTest.php index 34ee4d1..39c4a6f 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -377,6 +377,13 @@ class ViewTest extends TestCase my-class-component html, ], + [ + 'page-with-component-with-prop-which-value-contains-spaces-and-numbers', + <<<'html' +

Hello, Constantine 1st the Great

+ html, + ['name' => 'Constantine 1st the Great'], + ], ]; } diff --git a/tests/views/pages/page-with-component-with-prop-which-value-contains-spaces-and-numbers.php b/tests/views/pages/page-with-component-with-prop-which-value-contains-spaces-and-numbers.php new file mode 100644 index 0000000..622b833 --- /dev/null +++ b/tests/views/pages/page-with-component-with-prop-which-value-contains-spaces-and-numbers.php @@ -0,0 +1 @@ + \ No newline at end of file