[Formatting Bug]: Custom Directive with space around construct
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
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
This is still an issue.
@shufo I don't mind having a go trying to resolve it if you can point me in the right direction.
@leettaylor Thanks for creating the issue and your offer. I think this behaviour should be fixed to allow one space around construct or delete space if it is not necessary.
It might be difficult to point where it should be fixed so I'll take a look around custom directive formatting section.
Looks like I submitted a similar issue but with real directives #941, the following code has the same indentation issue
@if ($i >= 1)
@break
@endif
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
Still an issue
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
Still an issue
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
Still an issue
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
Still an issue
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
Still an issue
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
Still an issue