Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Fix self-closing tags with newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVanderbist committed Oct 8, 2018
1 parent 94d2f7d commit 44c3dd5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function parseSelfClosingTags(string $viewContents, Component $compone
{
$prefix = $this->bladeX->getPrefix();

$pattern = "/<\s*{$prefix}{$component->tag}\s*(?<attributes>.*)\s*\/>/";
$pattern = "/<\s*{$prefix}{$component->tag}\s*(?<attributes>(?:\s+[\w\-:]+(=(?:\\\"[^\\\"]+\\\"|\'[^\']+\'|[^\'\\\"=<>]+))?)*\s*)\/>/";

return preg_replace_callback($pattern, function (array $matches) use ($component) {
$attributes = $this->getAttributesFromAttributeString($matches['attributes']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<div>
<div class="error">
my message
</div>
<div class="error">
my message
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
['type' => 'error','message' => $message])
); ?>
<?php echo $__env->renderComponent(); ?>
<?php $__env->startComponent(
'components.alert',
array_merge(app(Spatie\BladeX\ContextStack::class)->read(),
['type' => 'error','message' => $message])
); ?>
<?php echo $__env->renderComponent(); ?>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<?php $message = 'my message' ?>

<alert type="error" :message="$message" />

<alert
type="error"
:message="$message"
/>

0 comments on commit 44c3dd5

Please sign in to comment.