Skip to content

Commit 7d5e992

Browse files
committed
Fix for Javascript frameworks
- This will make the helper ignore @{{}}, to prevent breaking javascript frameworks.
1 parent a60170d commit 7d5e992

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/BladeFiltersCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BladeFiltersCompiler
1212
*/
1313
public function compile($value)
1414
{
15-
return preg_replace_callback('/(?<={{)(.*?)(?=}})/mu', function ($matches) {
15+
return preg_replace_callback('/(?<=([^@]{{))(.*?)(?=}})/mu', function ($matches) {
1616
return $this->parseFilters($matches[0]);
1717
}, $value);
1818
}

tests/BladeFiltersTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,11 @@ public function it_throws_exception_when_missing_filter()
7171

7272
$this->assertEquals($result->exception->getPrevious()->getMessage(), 'this_filter_does_not_exist');
7373
}
74+
75+
/** @test */
76+
public function at_curly_brace_js_syntax_ignored()
77+
{
78+
$result = $this->get('/blade-filters/ignore-js')
79+
->assertSee('<h1>{{ val.title | title }}</h1>');
80+
}
7481
}

tests/views/ignore-js.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>@{{ val.title | title }}</h1>

0 commit comments

Comments
 (0)