laravel-blade-snippets-vscode icon indicating copy to clipboard operation
laravel-blade-snippets-vscode copied to clipboard

Incorrect indentation inside directives

Open joaopms opened this issue 6 years ago • 14 comments

Formatting a Blade document is incorrectly indenting code inside directives.

Expected output:

@section('content')
    <p>Hello world</p>
@endsection

Actual output:

@section('content')
<p>Hello world</p>
@endsection

joaopms avatar May 10 '19 14:05 joaopms

Similar with @for directives.

OS: Windows 10, Linux Fedora 29 VS Code: 1.33.1 Laravel Blade Snippets: 1.20.0

Expected output:

<select class="form-control custom-select" name="week">
    @for ($i = 0; $i < 52; $i++)
        <option value="{{ $i }}">Week {{ $i+1 }}</option>
    @endfor
</select>

Actual output:

<select class="form-control custom-select" name="week">
    @for ($i = 0; $i < 52; $i++) <option value="{{ $i }}">Week {{ $i+1 }}</option>
        @endfor
</select>

Stevemaster92 avatar May 15 '19 14:05 Stevemaster92

I have this issue, too. Formatting any blade.php file results in any blade indentation within blade directives being removed.

lrpinto avatar Sep 13 '19 18:09 lrpinto

does anyone solved it? i have the same issue too and i'm using phpStorm meanwhile :/

mtzrmzia avatar Oct 09 '19 14:10 mtzrmzia

Yeah its a hard issue to deal with, anyone have any other blade formatting plugins?

andrewmclagan avatar Dec 03 '19 11:12 andrewmclagan

I'd love for this to get implemented. Is anybody still maintaining this project?

MartinP7r avatar Feb 05 '20 02:02 MartinP7r

also discussed in #61

Slivicon avatar Mar 16 '20 18:03 Slivicon

🦗 🦗 🦗

elliottregan avatar Apr 17 '20 21:04 elliottregan

:/ any other solutions than this?

alexkerber avatar May 09 '20 14:05 alexkerber

:/ any other solutions than this?

You can use beautifier. This gist has some bugs but with some effort you can make it work. Look at the comments below the gist.

https://gist.github.com/fzldn/a27973ff7e4c8e3738b0e06e525f7403

tsekka avatar May 10 '20 15:05 tsekka

You can use beautifier. This gist has some bugs but with some effort you can make it work. Look at the comments below the gist.

https://gist.github.com/fzldn/a27973ff7e4c8e3738b0e06e525f7403

@tsekka Thank you for sharing. For now, it seems a better solution for indentation formatting. Beautifier converts all blade directives to html tag format in order to process document like html.

onecentlin avatar May 11 '20 03:05 onecentlin

:/ any other solutions than this?

You can use beautifier. This gist has some bugs but with some effort you can make it work. Look at the comments below the gist.

https://gist.github.com/fzldn/a27973ff7e4c8e3738b0e06e525f7403

Still not a solution in my eyes that you have to change this every time they update the plugin. :/

alexkerber avatar May 11 '20 09:05 alexkerber

Broken for years lol

ParachainsDev avatar Feb 06 '21 02:02 ParachainsDev

https://github.com/shufo/vscode-blade-formatter

kylemilloy avatar Feb 12 '22 20:02 kylemilloy

Since this is still broken, you can use the Laravel Blade Formatter package instead of this for formatting.

And be sure to disable the formatting from this package in your settings:

"blade.format.enable": true,

jerothor avatar Jan 20 '23 02:01 jerothor