Skip to content

Commit c61519b

Browse files
authored
feat(view): add view comments (#1356)
1 parent a0802e0 commit c61519b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/view/src/Elements/TextElement.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public function __construct(
1919
public function compile(): string
2020
{
2121
return str($this->text)
22+
// Render {{-- --}}
23+
->replaceRegex(
24+
regex: '/{{--(.|\n)*?--}}/',
25+
replace: '',
26+
)
2227
// Render {{
2328
->replaceRegex(
2429
regex: '/{{(?<match>.*?)}}/',

tests/Integration/View/TempestViewRendererTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,4 +718,13 @@ public function test_unclosed_php_tag(): void
718718

719719
$this->assertSame('hi', $html);
720720
}
721+
722+
public function test_view_comments(): void
723+
{
724+
$html = $this->render(<<<'HTML'
725+
<p>{{-- this is a comment --}}this is rendered text</p>{{-- this is a comment --}}
726+
HTML);
727+
728+
$this->assertSnippetsMatch('<p>this is rendered text</p>', $html);
729+
}
721730
}

0 commit comments

Comments
 (0)