Closed zepfietje closed 1 year ago
The expected behavior of these things seems opposite to that of https://github.com/Stillat/blade-parser-typescript/issues/13
I'll see what I can do with the internal prettier stuff, though 🤔
Yeah it's tricky. Have a look at the Filament codebase if you like: https://github.com/filamentphp/filament. We have a lot of places where we really need to put things on multiple lines.
💡 I suppose I could check if the {{
and }}
were intentionally put on separate lines and swap that behavior internally (this also has the added benefit if you intentionally put them on a single line it stays that way)
Interesting idea! Let me know if you want me to test anything.
I've got the behavior much much better with this new concept (this new behavior will also maintain the current behavior of #13 ). For this input:
<label
{{
$attributes
->whereDoesntStartWith('wire:model')
->class(['flex gap-3 text-sm'])
}}
>
</label>
it will produce:
<label
{{
$attributes
->whereDoesntStartWith("wire:model")
->class(["flex gap-3 text-sm"])
}}
></label>
and for the following:
<div {{ $attributes->class([
'some classes',
match ($someCondition) {
true => 'more classes foo bar baz',
default => 'even more classes foo bar baz',
},
]) }} more attributes class="one two three" something="else">
</div>
it produces
<div
{{
$attributes->class([
"some classes",
match ($someCondition) {
true => "more classes foo bar baz",
default => "even more classes foo bar baz"
},
])
}}
more
attributes
class="one two three"
something="else"
></div>
It will place the {{
and }}
on its own line and indent the contents relative to that (keeping the start/end inline with those was becoming a nightmare).
If that behavior looks good to you I'll tag a new version 🙂
Wow that looks perfect, John! Tag that version, then I'll test it on my codebases.
We should be pretty close to a perfect formatter now!! 😄
This is now available in release 1.1.4
Often long chains inside
{{ }}
are put on multiple lines. However, after formatting it's all put on a single line.Input
Output
Expected input to remain unchanged or be something like: