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

Commit

Permalink
Merge branch 'master' of github.com:spatie/lararvel-blade-x
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Sep 29, 2018
2 parents f402806 + 82c9237 commit 88e8aee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The package will automatically register itself.

## Usage

A the contents of a component can be stored in a simple Blade view.
The contents of a component can be stored in a simple Blade view.

```blade
{{-- resources/views/components/myAlert.blade.php --}}
Expand Down
4 changes: 2 additions & 2 deletions src/BladeXCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public function compile(string $viewContents): string

protected function parseComponentHtml(string $viewContents, BladeXComponent $bladeXComponent)
{
$pattern = "/<\s*{$bladeXComponent->name}[^>]*>((.|\n)*?)<\s*\/\s*{$bladeXComponent->name}>/m";
$pattern = "/<\s*{$bladeXComponent->name}[^>]*(?:\/>|>((?:.|\n)*?)<\s*\/\s*{$bladeXComponent->name}>)/m";

return preg_replace_callback($pattern, function (array $regexResult) use ($bladeXComponent) {
[$componentHtml, $componentInnerHtml] = $regexResult;
[$componentHtml, $componentInnerHtml] = $regexResult + ['', ''];

return "@component('{$bladeXComponent->bladeViewName}', [{$this->getComponentAttributes($componentHtml)}])"
.$this->parseComponentInnerHtml($componentInnerHtml)
Expand Down

0 comments on commit 88e8aee

Please sign in to comment.