Closed pascalbaljet closed 1 year ago
I will think on if I can work around this in an easy way - but this is a prettier issue at the end of the day (and not related to the Blade functionality specifically).
Tracked the issue down to custom elements that have the same name as void elements, which causes issues with prettier.
As of 1.6.5
, if the custom elements are not lower case, the formatter will assume you want to treat them as a custom tag. When it detects this it does some internal magic to prevent prettier getting confused.
The following tags now have test coverage when used as custom HTML tags:
Thanks for responding so quickly! I found that it works for most templates. Still, on some templates I get an Unexpected character "EOF"
error:
["ERROR" - 12:26:05] Error formatting document.
["ERROR" - 12:26:05] Unexpected character "EOF" (25:27)
23 | <VoidBWAi131qm5cAJkABLink href="B60gF4HrsgtqTNESP1oSrgQyUgAB" class="text-sm text-gray-600 underline hover:text-gray-900">
24 | <BEZnwESjLTNa2CHtYnmF0LlRB />
> 25 | </VoidBWAi131qm5cAJkABLink
| ^
You can reproduce it by wrapping the Link example in a div.
Some extra info: the same happens when you wrap the Link example in an if-statement, wrapped in a div. The error is different, though:
{{-- this works: --}}
@if (true)
<Link href="{{ route('profile.show') }}" class="text-sm text-gray-600 underline hover:text-gray-900">
{{ __('Edit Profile') }}
</Link>
@endif
{{-- this doesn't work: --}}
<div>
@if (true)
<Link href="{{ route('profile.show') }}" class="text-sm text-gray-600 underline hover:text-gray-900">
{{ __('Edit Profile') }}
</Link>
@endif
</div>
Console output:
SyntaxError: Unpaired condition control structure
1| <div>
>2| @if (true)
3| <VoidBMIgYwWDHSRjItyBLink href="{{ route('profile.show') }}" class="text-sm text-gray-600 underline hover:text-gray-900">
4| {{ __('Edit Profile') }}
5| </VoidBMIgYwWDHSRjItyBLink
Some extra info: the same happens when you wrap the Link example in an if-statement, wrapped in a div. The error is different, though:
{{-- this works: --}} @if (true) <Link href="{{ route('profile.show') }}" class="text-sm text-gray-600 underline hover:text-gray-900"> {{ __('Edit Profile') }} </Link> @endif {{-- this doesn't work: --}} <div> @if (true) <Link href="{{ route('profile.show') }}" class="text-sm text-gray-600 underline hover:text-gray-900"> {{ __('Edit Profile') }} </Link> @endif </div>
Console output:
SyntaxError: Unpaired condition control structure 1| <div> >2| @if (true) 3| <VoidBMIgYwWDHSRjItyBLink href="{{ route('profile.show') }}" class="text-sm text-gray-600 underline hover:text-gray-900"> 4| {{ __('Edit Profile') }} 5| </VoidBMIgYwWDHSRjItyBLink
Thanks for all the extra info - will work to get something going to resolve this! 🙌
Just an update that the described issue with closing tags has been resolved as of 1.6.6
Thanks, works as a charm! Just reformatted 140+ Blade files without a glitch.
I've been testing the prettier plugin, and it's pretty solid! However, it sometimes fails with custom HTML elements.
Somehow these two examples work perfectly:
But when I replace
Custom
withLink
, I get an error.Error Log: