Open vielhuber opened 5 years ago
We need parser for this
Can you provide some starter instructions how to contribute and where to start?
Hi @vielhuber, I think this would require a separate prettier plugin which consists out of a blade parser and custom formatting rules for blade templates. This probably requires a lot of work, see https://prettier.io/docs/en/plugins.html for more details.
@vielhuber Can blade
using not only in php?
The blade templates always have the .php extension (filename is always *.blade.php).
@czosel i think we should do this inside this plugin
I have recently created a formatter for blade. Using prettier and plugin-php inside it. https://github.com/shufo/blade-formatter It's not based on blade dedicated lexer or parser so supported syntax is limited. I hope plugin-php supports blade officially.
@vielhuber, GitHub's Linguist has .blade
and .blade.php
as the extensions for blade templates. I understand that .blade
is not standard, but it's trivial to support that extension in addition to the official .blade.php
scoped extension.
@shufo, it's cool that you've started work on something. However, it would be nice if your project were either a prettier plugin, or merged into this plugin. I don't like the idea of having to use another CLI tool just for blade templates when I'm already using Prettier with this plugin.
@shufo: Is there any way to run both blade-formatter and plugin-php at the same time?
For me it seems that plugin-php also formats blade.php files and gets in conflict with blade-formatter (which runs with RunOnSave).
Do you consider making a vscode prettier plugin for that?
FWIW, using the html
parser formats pretty well imo, it does kind of fail at formatting
the @
directives and blade brackets {{ }}
, but im okay with manually fixing those after running the formatting on a blade file.
Does anybody know: Is there any way to run both blade-formatter and plugin-php at the same time?
I both use the plugins and they seem to work quite good, however when I am formatting a *.blade.php file, the php-prettier parser interfers. it should ignore that types of files and let blade-formatter do it's job.
Did you already try adding *.blade.php to .prettierignore?
Jup, that works! Thanks in advance!
*.blade.php
how to add *blade.php to .prettierignore
Is there anyone working on this currently? Otherwise, could someone point me to the HTML parser code so I can take a look at it? HTML parser does 99% of the job except ignores "@" rules, so it seems like the closest place to start. I could potentially help on that.
Hi @davidwebca, I donโt think anyone is currently working on this. The HTML parser is not part of this repository, but of the main prettier project: https://github.com/prettier/prettier/tree/main/src/language-html
Would be great to see this start working. I think a lot of us Laravel users (myself included) are excited to use the new Tailwind plugin, but we can't use it on any of our blade files.
I wish I could be more helpful in making this happen. Thank you to anyone who has the time and ability to get blade files working.
https://twitter.com/taylorotwell/status/1486085543960186882
Don't know what is involved to get this to work but Taylor said this โ๐ผ
we'll (@roots) also contribute $500 on top of the $1,000 put up by taylor
Update: It's $3,500 ๐
There seems to be a work in progress here: https://github.com/ryangjchandler/prettier-plugin-blade
Nice! Glad to hear Tailwind releasing Prettier support kicked the thing, I've been watching this issue for so long I was just about to scratch the issue myself. I'm not after the bounty, I'll leave that to Ryan, but I'll lend a hand by looking through the code and testing it. ๐ฅ
I noticed this issue is recently active again so I released prettier plugin for blade
https://github.com/shufo/prettier-plugin-blade
It's not lexer based plugin generating ASTs, so there is a bit of limitation, but it generally works fine for normal blade templates.
https://user-images.githubusercontent.com/1641039/151354641-6305805e-8e0c-4226-8331-64195f85160e.mp4
Ryan's work would be great if it could be done! I'm looking forward to it.
@jpickwell sorry for late!
@czosel @olivernybroe What do you think embed it here? I think it will be convenient for developers
@olivernybroe and I are hoping we can cover a lot of the edge cases that other formatters for Blade don't cover yet. We'll be using a lexer & parser to tackle this.
@alexander-akait Yeah, it probably fits to the scope of the PHP plugin. Back when this was brought up for the first time I was hesitant, but mostly because of the complexity involved. From the user's perspective, it would be nice to get PHP and blade support out of the same plugin I'd say :+1:
Hello!
The blade templating engine in laravel is not supported at the moment (it seems).
Are there any plans to add this in the future?
Is this hard to do and can I help out?