shufo / prettier-plugin-blade

Format your blade template using Prettier
https://www.npmjs.com/package/@shufo/prettier-plugin-blade
MIT License
318 stars 8 forks source link

[Formatting Bug]: does not format when inline directive and if directive mixed #199

Closed theMosaad closed 8 months ago

theMosaad commented 1 year ago

Version

1.8.12

Template before formatting

<div @php($counter = 1) >
     <x-share>
    @if ($counter)
          {{--  --}}
    @endif
  </x-share>
</div>

Template after formatting

<div
  @php($counter = 1) >
     <x-share>
    @if ($counter)
          {{--  --}}
    @endif
  </x-share>
</div>

Expected Behaviour

Expected

Config

This test is done with a fresh Prettier VSCode plugin & no config rules aside from the essential to make this plugin work:

{
  "plugins": ["@shufo/prettier-plugin-blade"],
  "overrides": [
    {
      "files": ["*.blade.php"],
      "options": {
        "parser": "blade"
      }
    }
  ]
}

Workarounds

  1. replacing @php($counter = 1) with @php $counter = 1 @endphp.
  2. remove the @if statement inside the x-share component.

Relevant log output

<div @php($counter = 1) >
        <x-share>
    @if ($counter)
       {{--  --}}
    @endif
    </x-share>
</div>
github-actions[bot] commented 12 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

shufo commented 8 months ago

Fixed at https://github.com/shufo/prettier-plugin-blade/releases/tag/v1.13.4. Thanks for your patience!