vscode-blade-formatter icon indicating copy to clipboard operation
vscode-blade-formatter copied to clipboard

[Formatting Bug]: Chaining method issue

Open dicktornfeldt opened this issue 1 year ago • 8 comments

Platform

MacOS

Template before formatting

<flux:tab :data-selected="request()->routeIs('meals*')" href="{{ route('meals.index') }}">

Template after formatting

<flux:tab :data-selected="request() - > routeIs('meals*')" href="{{ route('meals.index') }}">

Expected Behaviour

The arrow between request() and routeIs() should not get expanded

Relevant log output

No response

dicktornfeldt avatar Sep 30 '24 08:09 dicktornfeldt

I understand that it's because im using Flux components instead of basic Laravel components after reading: #506

dicktornfeldt avatar Oct 03 '24 10:10 dicktornfeldt

@dicktornfeldt I have the same issue with Flux components, did you find a fix for this? Because I would like to use VS Code (actually Cursor) instead of PhpStorm but I have issues with the formatting of Blade files.

Because for example I would like to use the following:

<flux:button size="sm" icon="chevron-up" :disabled="$item->user_id === auth()->id()">
    {{ $upvoteCount }}
</flux:button>

But after saving it formats like this

<flux:button size="sm" icon="chevron-up" :disabled="$item - > user_id === auth() - > id()">
    {{ $upvoteCount }}
</flux:button>

Thanks!

ferremek avatar Nov 28 '24 07:11 ferremek

Yeah, I had to disable the extension alltogether because it made it unusable to have to deal with those spacing :(

jpmurray avatar Jan 05 '25 15:01 jpmurray

You can disable formating for a line of code just like this:

{{-- blade-formatter-disable --}}
<flux:accordion.item :expanded="$loop->first">
{{-- blade-formatter-enable --}}

dadastudio avatar Feb 06 '25 05:02 dadastudio

For strings the problem can be bypassed by passing the variable in curly brackets, icon="{{ $item->icon }}" rather than :icon="$item->icon". Does not seem to work for booleans like disabled="{{ $item->disabled }}" though.

hallinmattias avatar Feb 27 '25 14:02 hallinmattias

Same problem here, I solved using @ instead of : it works but its not "the correct way"

<flux:navlist.item ... @current="request()->routeIs('admin.dashboard')" ...>

seems to work because the formatter it's ignoring it

Ceneka avatar Apr 10 '25 15:04 Ceneka

I got same error,

<flux:navlist.item :href="tenant_route('tenant.settings.business_profile')" :current="request() -> routeIs('tenant.settings.business_profile')" wire:navigate>
       { __('Business Profile') }}
</flux:navlist.item>

And after formated

<flux:navlist.item :href="tenant_route('tenant.settings.business_profile')" :current="request() - > routeIs('tenant.settings.business_profile')" wire:navigate>
       { __('Business Profile') }}
</flux:n

rizkidarmawan21 avatar Apr 28 '25 15:04 rizkidarmawan21

i got this error to in livewire starter kit

ahmadfahmidj avatar Jun 07 '25 03:06 ahmadfahmidj

Please see @dadastudio ’s comment. I have found this similar workaround useful:

<flux:input wire:model="myfield"
  {{— blade-formatter-disable-next-line —}}
  :disabled="$this->myBooleanValue()"
  placeholder="My Placeholder" />

nissicreative avatar Jul 07 '25 20:07 nissicreative

Sorry for late reply. v0.25.0 released just now introduces Component Prefix option that allow specify custom component name like flux

Image

Please upgrade extension to latest version and specify this option as x-,livewire,flux

This option will preventing unexpected formatting of component attribute.

shufo avatar Jul 12 '25 00:07 shufo

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] avatar Sep 10 '25 02:09 github-actions[bot]