Skip to content

Commit

Permalink
fix: 🐛 incorrect format when inline directive and endif exists
Browse files Browse the repository at this point in the history
refs: shufo/prettier-plugin-blade#199. It
occurs when inlined directive like `@php` followed by `@if` ~ `@endif`
directive
  • Loading branch information
shufo committed Nov 5, 2023
1 parent 9e1e075 commit 2010b5d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions __tests__/fixtures/snapshots/inline_php_directive.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
------------------------------------options----------------------------------------
{}
------------------------------------content----------------------------------------
<div @php($counter = 1)>
<x-share>
@if ($counter)
{{-- --}}
@endif
</x-share>
</div>
------------------------------------expected----------------------------------------
<div @php($counter = 1)>
<x-share>
@if ($counter)
{{-- --}}
@endif
</x-share>
</div>
4 changes: 2 additions & 2 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ export default class Formatter {
.then((target) => this.preserveRawBladeBrace(target))
.then((target) => this.preserveConditions(target))
.then((target) => this.preservePropsBlock(target))
.then((target) => this.preserveInlineDirective(target))
.then((target) => this.preserveInlinePhpDirective(target))
.then((target) => this.preserveInlineDirective(target))
.then((target) => this.preserveBladeDirectivesInScripts(target))
.then((target) => this.preserveBladeDirectivesInStyles(target))
.then((target) => this.preserveCustomDirective(target))
Expand Down Expand Up @@ -231,8 +231,8 @@ export default class Formatter {
.then((target) => this.restoreCustomDirective(target))
.then((target) => this.restoreBladeDirectivesInStyles(target))
.then((target) => this.restoreBladeDirectivesInScripts(target))
.then((target) => this.restoreInlinePhpDirective(target))
.then((target) => this.restoreInlineDirective(target))
.then((target) => this.restoreInlinePhpDirective(target))
.then((target) => this.restoreConditions(target))
.then((target) => this.restoreRawBladeBrace(target))
.then((target) => this.restoreBladeBrace(target))
Expand Down

0 comments on commit 2010b5d

Please sign in to comment.