question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Will not format classes within Blade files.

See original GitHub issue

I’m using VS Code and I have everything installed as required, format on save is on.

When I save, I get an error on the bottom that says Extension 'Prettier - code formatter' is configured as formatter but can not format 'Blade' files.

I have this in my .prettierrc as noted in another issue, but it’s not affecting anything:

{
    "overrides": [
        {
            "files": "*.blade.php",
            "options": {
                "parser": "html"
            }
        }
    ]
}

If I run npx prettier --check resources/views it states everything is formatted properly (which it’s not)

Interestingly, if I change a blade file to be a plain HTML file,format on save still does not do anything, but running npx prettier will then find the issues.

What am I doing wrong?

Is there no support for the formatter in blade files within a Laravel project?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:12
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
rappasoftcommented, Feb 9, 2022

@nwlr My main goal is to just sort the Tailwind classes within a Blade file. You’re saying installing your plugin and setting the blade parser to HTML makes it pick up the Tailwind classes using the tailwindcss-prettier plugin?

0reactions
howducommented, Mar 25, 2022

There’s a blade plugin which works really well prettier-plugin-blade

{
   "tabWidth": 4,
    "wrapAttributes": "auto",
    "sortTailwindcssClasses": true,
    "plugins": ["@shufo/prettier-plugin-blade"]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Format Laravel Blade Code in Visual Studio Code?
First go to "Visual Studio Code" Settings and search for the option "files.associations" If that option is not available in your settings.
Read more >
Laravel Blade formatter - Visual Studio Marketplace
Extension for Visual Studio Code - Laravel Blade formatter for VSCode. ... To disable formatting in your file, you can use blade comments...
Read more >
Some <span> tags are not properly formatted inside HTML ...
Some <span> tags are not properly formatted inside HTML and Blade files ; State, Declined ; Assignee, Rustam Vishniakov ; Subsystem, PHP Formatter...
Read more >
shufo/blade-formatter - GitHub
This project aims to provide formatter for blade template because there is no official blade template formatter. Try it out on Online Demo....
Read more >
Blade Templates - The PHP Framework For Web Artisans
Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates. In fact, all Blade templates...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found