Closed claytonrcarter closed 9 months ago
Thanks for the deep dive on this! I'd appreciate a PR to get the ball rolling and I can start diving in more later this week 💪
Happy to help! I've opened #90 with my fix for this, and #91 with some other issues I noticed.
Available with release 2.1.0
Hi! I've been playing around w/ the prettier plugin and it's great. Thank you for it! I've noticed, however, that Blade directives with multiple parameters are not supported. There aren't many such directives, but
@include
(et al) and@each
come to mind. In particular, we make heavy use of@include()
to include subviews, and we almost always have to pass data into them. Here's an example adapted from the Laravel docs:Example Input
Expected output
Actual output (as of latest, v2.0.0)
unchanged
Possible solution
I hacked around a little bit and and – based on a thoroughly incomplete understanding of the codebase – found that the issue is happening in at least 2 places:
hasValidPhp()
is passinggetPhpContent()
to the validator, but in this case, that content looks like( ... , ...)
which is not valid PHP, because commas are not allowed there.printDirective()
is also usinggetPhpContent()
, so it's also handling invalid PHP.I see that there is already special handling for
forelse
in these places (eg ingetContent()
andprintDirective()
) so perhaps special handling needs to be added forinclude
, etc?As I said, I'm not familiar with the codebase, but I have been able to put together some failing tests for this, as well as hack together some code to get them to pass. But they are just hacks and I don't know how useful they would be for a proper fix. Would you like me to push them to a PR anyway, just to get the ball rolling?