Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
theMosaad opened this issue May 16, 2023 · 3 comments · Fixed by shufo/blade-formatter#887
Assignees
Labels
bug Something isn't working

Comments

@theMosaad
Copy link

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

  • @php($counter = 1) not to wrap and stay in the same line like <div @php($counter = 1) >.
  • <x-share> to have the same indent as </x-share>.
  • the space between @php($counter = 1) and the closing bracket > to be removed.

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>
@theMosaad theMosaad added the bug Something isn't working label May 16, 2023
@github-actions
Copy link
Contributor

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 github-actions bot added the Stale label Jul 16, 2023
@shufo shufo removed the Stale label Jul 16, 2023
@github-actions
Copy link
Contributor

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 github-actions bot added the Stale label Sep 15, 2023
@shufo shufo removed the Stale label Sep 18, 2023
shufo added a commit to shufo/blade-formatter that referenced this issue Nov 5, 2023
refs: shufo/prettier-plugin-blade#199. It
occurs when inlined directive like `@php` followed by `@if` ~ `@endif`
directive
@shufo shufo changed the title [Formatting Bug]: [Formatting Bug]: does not format when inline directive and if directive mixed Nov 5, 2023
@shufo
Copy link
Owner

shufo commented Nov 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants