shufo / prettier-plugin-blade

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

[Formatting Bug]: Weird indentation #255

Closed calebdw closed 2 months ago

calebdw commented 7 months ago

Version

1.13.4

Template before formatting

@extends('...')

@section('buttons')
    <x-button.link
        type="primary"
        :href="route('...', $station)"
    >
        <x-heroicon-s-chevron-left class="ml-0 mr-2 !h-4 !w-4" />
        Dashboard
    </x-button>
@endsection

@section('main')
    <h1>Additional Operator</h1>
    <x-form :model="$station">
        <div class="space-y-4">
            <x-form.select
                name="additional_operator_id"
                :options="$operators"
                class="md:w-1/3"
                placeholder
            />

            <x-button.success type="submit" size="text-lg">
                Update
            </x-button.success>
        </div>
    </x-form>
@endsection

Template after formatting

@extends('...')

@section('buttons')
    <x-button.link type="primary" :href="route('...', $station)">
        <x-heroicon-s-chevron-left class="ml-0 mr-2 !h-4 !w-4" />
        Dashboard
        </x-button>
    @endsection

    @section('main')
        <h1>Additional Operator</h1>
        <x-form :model="$station">
            <div class="space-y-4">
                <x-form.select
                    name="additional_operator_id"
                    :options="$operators"
                    class="md:w-1/3"
                    placeholder
                />

                <x-button.success type="submit" size="text-lg">
                    Update
                </x-button.success>
            </div>
        </x-form>
    @endsection

Expected Behaviour

Formatting should not change.

Relevant log output

No response

github-actions[bot] commented 5 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 4 months ago

It seems <x-button.link open tag and </x-button> close tag was recognized as unmatched pair. (Though Laravel allows this syntax)

For workaround: use matched name for open/close tag for component.

<x-button.link>
</x-button.link>
github-actions[bot] commented 2 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