Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit ff446ab

Browse files
committed
Return original view contents if html parser does not work
1 parent ea2b197 commit ff446ab

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/TagHelperCompiler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ protected function parseHtml(string $viewContents, Helper $tagHelper)
7575
{
7676
$html = HtmlDomParser::str_get_html($viewContents, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = false);
7777

78+
if ($html === false) {
79+
return $viewContents;
80+
}
81+
7882
$elements = array_reverse($html->find($this->getTagSelector($tagHelper)));
7983

8084
foreach ($elements as $element) {

tests/Compilation/TagHelperCompilationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,10 @@ public function it_throws_an_exception_when_view_data_is_invalid()
8585

8686
view('views.invalid_data')->render();
8787
}
88+
89+
/** @test */
90+
public function it_compiles_empty_views()
91+
{
92+
$this->assertPhpMatchesViewSnapshot('empty');
93+
}
8894
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php return '';

tests/Compilation/stubs/views/empty.blade.php

Whitespace-only changes.

0 commit comments

Comments
 (0)