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]: Custom Directive with space around construct #930

Open
leettaylor opened this issue May 13, 2024 · 0 comments
Open

[Formatting Bug]: Custom Directive with space around construct #930

leettaylor opened this issue May 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@leettaylor
Copy link

leettaylor commented May 13, 2024

Version

1.41.1

Template before formatting

{{-- Not Working --}}

@loop ($items as $item)
    {{ $item }}
@endloop

@loopelse ($items as $item)
    {{ $item }}
@loopempty
    No items
@endloopelse

@loop($items as $item)
    {{ $item }}
@endloop

@loopelse($items as $item)
    {{ $item }}
@loopempty
    No items
@endloopelse

{{-- Working --}}

@foreach ($items as $item)
    {{ $item }}
@endforeach

@forelse ($items as $item)
    {{ $item }}
@empty
    No items
@endforelse

@foreach($items as $item)
    {{ $item }}
@endforeach

@forelse($items as $item)
    {{ $item }}
@empty
    No items
@endforelse

Template after formatting

{{-- Not Working --}}

@loop ($items as $item)
{{ $item }}
@endloop

@loopelse
    ($items as $item)
    {{ $item }}
    @loopempty
    No items
@endloopelse

@loop($items as $item)
{{ $item }}
@endloop

@loopelse($items as $item)
    {{ $item }}
    @loopempty
    No items
@endloopelse

{{-- Working --}}

@foreach ($items as $item)
    {{ $item }}
@endforeach

@forelse ($items as $item)
    {{ $item }}
@empty
    No items
@endforelse

@foreach ($items as $item)
    {{ $item }}
@endforeach

@forelse($items as $item)
    {{ $item }}
@empty
    No items
@endforelse

Expected Behaviour

The input should remain unchanged.

@loop ($items as $item)
    {{ $item }}
@endloop

@loopelse ($items as $item)
    {{ $item }}
@loopempty
    No items
@endloopelse

When a custom directive has a space around the construct the formatter moves the construct onto a new line which causes a syntax error. It also doesn't correctly apply indentation inside of the custom directive.

It works perfectly fine for a @foreach.

Relevant log output

No response

@leettaylor leettaylor added the bug Something isn't working label May 13, 2024
@leettaylor leettaylor changed the title [Formatting Bug]: Custom Directive [Formatting Bug]: Custom Directive with space around construct May 13, 2024
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

No branches or pull requests

2 participants