vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Add support for Blade (extension .blade.php) files

Open ghost opened this issue 6 years ago • 7 comments

Issue:

formatting does not work in "*.blade.php**" files..

ghost avatar May 08 '18 01:05 ghost

Hi @Rux77 . PHP support was recently added with PHP-CS-Fixer.

Does PHP language work if you change from blade? See https://code.visualstudio.com/docs/languages/overview#_changing-the-language-for-the-selected-file


If PHP does work, then TO-DO to add Blade language support:

  • [ ] Add VSCode language IDs to Unibeautify language for Blade: https://github.com/Unibeautify/unibeautify/blob/5eff024eb1373a259c252aef117a3b8f94b1f063/src/languages.json#L660
  • [ ] Add Blade language support to PHP-CS-Fixer: https://github.com/Unibeautify/beautifier-php-cs-fixer/blob/master/src/index.ts#L20
  • [ ] Update VSCode with latest Unibeautify & Beautifier for PHP-CS-Fixer

Glavin001 avatar May 08 '18 01:05 Glavin001

@szeck87 we need to think about the process for adding new languages and/or beautifiers. It should NOT be in Unibeautify core or the editor extensions (e.g. VSCode). We need some place which is:

  • [ ] central (not Unibeautify core, not editor extension, etc)
  • [ ] allow voting (prioritization)

🤔

Glavin001 avatar May 08 '18 01:05 Glavin001

@Glavin001 To be honest I think they should go in Unibeautify core. Languages have to be implemented there anyways. And we can make use of the issue wizard with templates.

stevenzeck avatar May 08 '18 03:05 stevenzeck

Sounds good. The multiple templates will be great for this. As long as beautifier-specific requests are routed to the beautifier's correct repository. I don't want Unibeautify core to get as crowded as Atom-Beautify has.

Glavin001 avatar May 08 '18 03:05 Glavin001

@Glavin001

Does PHP language work if you change from blade? See

No, it does not format the html elements.The blade files will contain html elements which will not be formatted in this case ( when I set the language to PHP) . but when I set the language to HTML it does trigger the formatting and works great.

Example of blade file (before formatting):

<html>

    <head>
             <title>App Name - @yield('title')</title>
 </head>
      <body>
     @section('sidebar') This is the master sidebar. 
     
     @endsection

        <div class="container">
            @yield('content')
    </div>
</body>
</html>

Example of blade file (after formatting):

<html>

    <head>
        <title>App Name - @yield('title')</title>
    </head>

    <body>
        @section('sidebar') This is the master sidebar. @endsection

        <div class="container">
            @yield('content')
        </div>
    </body>

</html>
  • another issue is some of the blade parts ( in the example above ) did not get formatted as expected, what is expected is something like this:
@section('sidebar') 
This is the master sidebar. 
@endsection

The thing is, I need the blade syntax highlighting which I can only see it in blade language.. Maybe If you can make it easier for the user to be able to do something like this:

    "unibeautify.language": {
        "html": [
            "htm",
            "blade"
        ],
    },

Thanks for your time

ghost avatar May 08 '18 09:05 ghost

Thank you for the details comment! This helps a lot.

https://github.com/Glavin001/atom-beautify/pull/2087 has an interesting solution to formatting Blade code. This is something which could be migrated to Unibeautify.

cc @szeck87

Glavin001 avatar May 08 '18 15:05 Glavin001

The thing is, I need the blade syntax highlighting which I can only see it in blade language.. Maybe If you can make it easier for the user to be able to do something like this:

    "unibeautify.language": {
        "html": [
            "htm",
            "blade"
        ],
    },

I could use such a feature to configure HTML+PHP to be formatted with the HTML rules. In my case it's a *.phtml file.

[2019-02-14 18:48:08.205] [exthost] [error] [Glavin001.unibeautify-vscode] provider FAILED
[2019-02-14 18:48:08.205] [exthost] [error] Error: Beautifiers not found for Language: HTML+PHP

chipco avatar Feb 14 '19 16:02 chipco