Closed zepfietje closed 1 year ago
Does this happen on every file, or just randomly as it progresses? If you've modified the cache location, could you share the .blade.format.json
file?
I'll be taking a look into this later today, and all extra information helps. Thanks!
Seems like it only happens the last so many files.
I haven't modified the cache location.
Already tried removing node_modules and reinstalling dependencies.
Let me know if you can reproduce it by simply running the formatter on the Filament 2.x branch.
Spotted the issue and released 1.4.8
Will keep these open for now, however 🙂
This is unrelated to the issue, but thought I'd mention it anyway. You are likely to receive some formatting failures due to unclosed elements/etc.
These come from this type of template:
@if ($isInline())
<x-slot name="labelPrefix">
@endif
....
@if ($isInline())
</x-slot>
@endif
This is a known limitation (and can be triggered in prettier without Blade, as well), and can easily be worked around by having those sections ignored (this will impact a very small # of files across both of your branches - also planning on having a shorter version of those ignore start/end flags sometime soon):
@if ($isInline())
{{-- format-ignore-start --}}<x-slot name="labelPrefix">{{-- format-ignore-end --}}
@endif
We could also use @capture
instead in those places probably, right, @danharrin?
https://github.com/ryangjchandler/blade-capture-directive
Same for the failures where we use {{ $tag }}
echoes to to define the HTML element to use like <{{ $tag }}>
.
The formatter will be able to handle pairs of dynamic tags:
<{{ $tag }}>
</{{ $tag }}>
It will also take things like the following (but I really don't recommend it 😅):
<@if($something)here @endif class="something">
</@if($something)here @endif>
<@unless($something)here @endunless more things>
</@unless($something)here @endunless>
If you make the one-off instances self closing things should also be fine: <{{ $tag }} />
. Its mainly just having part of the tag inside a structure like if/for/etc. that causes the issue
Ah I understand now. In which files did you spot those issues? We might be able to refactor that code.
These were the ones I noticed in the v2 branch 🙂
packages/forms/resources/views/components/checkbox.blade.php
packages/forms/resources/views/components/radio.blade.php
packages/forms/resources/views/components/toggle.blade.php
Thanks!
I think those could be solved using @capture
.
Potentially could refactor, yes
Going to close this issue now :)
These were the ones I noticed in the v2 branch 🙂
packages/forms/resources/views/components/checkbox.blade.php packages/forms/resources/views/components/radio.blade.php packages/forms/resources/views/components/toggle.blade.php
These have been refactored to use @capture
.
I've created a fresh PR that adds the formatter to Filament 2.x
You may want to take a look at the diff, @JohnathonKoster. 😄
On 1.4.7, when running the formatter on the Filament 2.x codebase, I'm getting a lot of errors in the output like:
[error] tests/resources/views/tables/fixtures/table.blade.php: Error: ENOENT: no such file or directory, mkdir '/Users/zepfietje/Code/filament/node_modules/prettier-plugin-blade/../../../_test/_cache/'
.