Plugin-php: Laravel blade support

Created on 24 Aug 2019  路  14Comments  路  Source: prettier/plugin-php

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?

discussion enhancement

Most helpful comment

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.

All 14 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aboyton picture aboyton  路  4Comments

ichiriac picture ichiriac  路  3Comments

alexander-akait picture alexander-akait  路  3Comments

alexander-akait picture alexander-akait  路  5Comments

virgofx picture virgofx  路  4Comments