allow props which values contains spaces and numbers

580-view-class-steroids
fadrian06 2 weeks ago
parent 52ec6b8803
commit 8c88b9d94a

@ -173,7 +173,7 @@ class View
} }
preg_match_all( preg_match_all(
"/<$this->componentPrefix-(?<component>[a-z-]+)\s*(?<props>([a-z]+=\"[a-zA-Z]+\"\s*)*)?\s*\/>/", "/<$this->componentPrefix-(?<component>[a-z-]+)\s*(?<props>([a-z]+=\"[^\"]+\"\s*)*)?\s*\/>/",
$view, $view,
$tagsMatches, $tagsMatches,
); );
@ -186,7 +186,7 @@ class View
$props = $tagsMatches['props'][$tagIndex] ?? ''; $props = $tagsMatches['props'][$tagIndex] ?? '';
preg_match_all( preg_match_all(
'/(?<name>[a-z]+)="(?<value>[a-zA-Z]+)"/', '/(?<name>[a-z]+)="(?<value>[^"]+)"/',
$props, $props,
$propsMatches, $propsMatches,
); );

@ -377,6 +377,13 @@ class ViewTest extends TestCase
my-class-component my-class-component
html, html,
], ],
[
'page-with-component-with-prop-which-value-contains-spaces-and-numbers',
<<<'html'
<h1>Hello, Constantine 1st the Great</h1>
html,
['name' => 'Constantine 1st the Great'],
],
]; ];
} }

Loading…
Cancel
Save