Stillat / blade-parser-typescript

A Laravel Blade parser, compiler, and static analyzer written in TypeScript.
https://stillat.com
MIT License
90 stars 3 forks source link

`@if` and `@unless` directive spacing #8

Closed zepfietje closed 1 year ago

zepfietje commented 1 year ago

As per usage in Laravel docs: https://laravel.com/docs/10.x/blade#if-statements.

Before formatting

@if ($foo)
@endif

Currently after formatting

@if($foo)
@endif

Expected after formatting

@if ($foo)
@endif
JohnathonKoster commented 1 year ago

Thanks for the report!

I've added a new internal classification for directives to help control the spacing. The following directives will now default to having 1 space after the directive name when formatting (the remaining defaults to 0 spaces):

If you'd like to change the spacing from the defaults, you may create a .blade.format.json file at the root of your project with the following settings:

{
    "spacesAfterDirective": 0,
    "spacesAfterControlDirective": 1
}

The spacesAfterControlDirective controls the number of spaces appearing after the directives in the list above, and spacesAfterDirective controls all other directives.

zepfietje commented 1 year ago

Thanks!