laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
166 stars 7 forks source link

Indentation problem while using livewire component, non-closing tags. #188

Closed anburocky3 closed 3 years ago

anburocky3 commented 3 years ago

I'm using the latest PHPStorm version with the latest idea plugin.

This is my current blade file

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Fonts -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">

    <!-- Styles -->
    <link rel="stylesheet" href="{{ mix('css/app.css') }}">

    @livewireStyles

    <!-- Scripts -->
    <script src="{{ mix('js/app.js') }}" defer></script>
</head>
<body class="font-sans antialiased">

    <div class="min-h-screen bg-gray-100">

    @livewire('navigation-dropdown')

    <!-- Page Heading -->
    {{-- <header class="bg-white shadow">
        <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
            {{ $header }}
        </div>
    </header> --}}

    <!-- Page Content -->
        <main>
            {{ $slot }}
        </main>
    </div>

@stack('modals')

@livewireScripts
</body>
</html>

If I format it using PHPStorm IDE, it messes up with the indentation.

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Fonts -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">

    <!-- Styles -->
    <link rel="stylesheet" href="{{ mix('css/app.css') }}">

@livewireStyles

<!-- Scripts -->
    <script src="{{ mix('js/app.js') }}" defer></script>
</head>
<body class="font-sans antialiased">

<div class="min-h-screen bg-gray-100">

@livewire('navigation-dropdown')

<!-- Page Heading -->
{{-- <header class="bg-white shadow">
    <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
        {{ $header }}
    </div>
</header> --}}

<!-- Page Content -->
    <main>
        {{ $slot }}
    </main>
</div>

@stack('modals')

@livewireScripts
</body>
</html>
adelf commented 3 years ago

Formatting issues in the Blade plugin is a long story... I'll try to analyze the issue, but I think the reason is somewhere inside the Blade plugin.

anburocky3 commented 3 years ago

Yea in the particular file the problem arising. I tried with other blade files with livewire, it's working as expected. Don't know why is it happening.

I tried with Import optimizes, code cleanup in both cases, I can see that problem exist.

adelf commented 3 years ago

I see the problem with @livewireStyles. There is some bug with <!-- Styles --> comment. After removing it - it indents correctly. Maybe better to write here: https://youtrack.jetbrains.com/newIssue and choose PhpStorm product.

About body: you can remove it from non-indenting list: image

anburocky3 commented 3 years ago

Even if I remove all the @livewireStyles & @livewireScripts it's still not formatting good.

anburocky3 commented 3 years ago
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>@yield('title') - {{ config('app.name', 'Laravel') }}</title>

    <link href="https://www.cyberdudenetworks.com/assets/img/assets/favicon.png" rel="icon" type="image/png">

    <!-- Fonts -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">

    <!-- Styles -->
    <link rel="stylesheet" href="{{ mix('css/app.css') }}">

    <!-- Scripts -->
    <script src="{{ mix('js/app.js') }}"></script>
</head>
<body class="font-sans antialiased">

<div class="min-h-screen bg-gray-100">
    <!-- Page Content -->
    <main class="container mx-auto mt-5">
        {{ $slot }}
    </main>
</div>

@stack('modals')

</body>
</html>

Even these are not formatting. Check inside body.

adelf commented 3 years ago

Have you removed body from the non-indenting list?