Stillat / blade-parser-typescript

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

Get weird indentation inside @if directive #104

Closed Lakshan-Madushanka closed 3 months ago

Lakshan-Madushanka commented 3 months ago

Thanks for this valuable package but my code block gets weird indentations in the below code. I did everything to fix it for hours but no luck.

Input

<div
    @click="if($wire.loginRequired){return}; isLiked = !isLiked; showUsers=false"
    wire:click="handle('{{ $key }}', '{{ $value["model"] }}')"
    @if ($authMode)
        @mouseover="
              if(
                  !$wire.loginRequired &&
                  $wire.reactions['{{ $key }}']['count'] > 0 &&
                   !showUsers
               ) {
                      showUsers = true;
                      $wire.lastReactedUser('{{ $key }}')
                  }
              "
    @endif
    class="flex cursor-pointer items-center"
    title="like"
>

Output

<div
    @click="if($wire.loginRequired){return}; isLiked = !isLiked; showUsers=false"
    wire:click="handle('{{ $key }}', '{{ $value["model"] }}')"
    @if ($authMode)
           @mouseover
            ="
                                                                    if(
                                                                        !$wire.loginRequired &&
                                                                        $wire.reactions['{{ $key }}']['count'] > 0 &&
                                                                         !showUsers
                                                                     ) {
                                                                            showUsers = true;
                                                                            $wire.lastReactedUser('{{ $key }}')
                                                                        }
                                                                    "
  @endif
  class="flex cursor-pointer items-center"
  title="like"
>
JohnathonKoster commented 3 months ago

Thanks for the report! Are you using the default settings (just to help debug when I look into it)?

Thanks!

Lakshan-Madushanka commented 3 months ago

Yes. Here the link it is an open-source package due to be released soon.

JohnathonKoster commented 3 months ago

Thanks for the extra info, it really helps! I'll update here once I start working through this and have a fix 👍

JohnathonKoster commented 3 months ago

That was a tough one! I've released a fix to prevent excessive indentation for these types of scenarios with 2.1.15