-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tempest\Highlight\Languages\Blade\Injections; | ||
|
||
use Tempest\Highlight\Highlighter; | ||
use Tempest\Highlight\Injection; | ||
use Tempest\Highlight\IsInjection; | ||
|
||
final readonly class BladeRawEchoInjection implements Injection | ||
{ | ||
use IsInjection; | ||
|
||
public function getPattern(): string | ||
{ | ||
return '({!!)(?<match>.*)(!!})'; | ||
} | ||
|
||
public function parseContent(string $content, Highlighter $highlighter): string | ||
{ | ||
return $highlighter->parse($content, 'php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/Languages/Blade/Injections/BladeRawEchoInjectionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Tempest\Highlight\Tests\Languages\Blade\Injections; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
use Tempest\Highlight\Languages\Blade\Injections\BladeRawEchoInjection; | ||
use Tempest\Highlight\Tests\TestsInjections; | ||
|
||
class BladeRawEchoInjectionTest extends TestCase | ||
{ | ||
use TestsInjections; | ||
|
||
#[Test] | ||
public function test_injection_raw_echo(): void | ||
{ | ||
$this->assertMatches( | ||
injection: new BladeRawEchoInjection(), | ||
content: '{!! count($foo) !!}', | ||
expected: '{!! <span class="hl-property">count</span>($foo) !!}', | ||
); | ||
} | ||
} |