GithubHelp home page GithubHelp logo

shufo / vscode-blade-formatter Goto Github PK

View Code? Open in Web Editor NEW
4.0K 9.0 30.0 8.29 MB

An opinionated Blade file formatter for VSCode

Home Page: https://marketplace.visualstudio.com/items?itemName=shufo.vscode-blade-formatter

License: MIT License

JavaScript 5.42% TypeScript 94.58%
laravel vscode vscode-extension formatter

vscode-blade-formatter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-blade-formatter's Issues

Laravel formatter is not working

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

Can't format blade files......

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Shows this error: Cannot invoke loadWASM more than once.

Doesn't formate any file.

format shortcut

Is it possible to implement a format shortcut?
I'd like to use the extension with no "format Enabled", and use a shortcut (Shift+Alt+F or similar) to format the current file.

not working

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

vscode laravel blade Formatter

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

vscode blade formatter error

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

Unwanted Line Breaks In Script

I use "force aligned" as the wrap attribute and the code down below

<script> var values = {!!json_encode($data['values']) !!}; </script>
is formatted into

<script>
var values = {
!!json_encode($data['values']) !!
};
</script>

and obviously, it causes an error.

some bugs

  • comment formating
{{-- test --}}

becomes

{{-- test
--}}
  • adds extra space b4 variables
 @foreach ($models->groupBy("$sort.name") as $group => $data)

becomes

 @foreach ($models->groupBy(" $sort.name") as $group => $data)
  • arrays with indentation gets flatten
@extends('pages.dashboard.pages', [
    'title' => __('Cards'),
    'sortList' => [
        'name' => __('Name'),
    ]
])

becomes

@extends('pages.dashboard.pages', [
'title' => __('Cards'),
'sortList' => [
'name' => __('Name'),
]
])
  • @php with indentation gets flatten
@php
    $test = 'hello;
@endphp

becomes

@php
$test = 'hello;
@endphp
  • some attributes doesn't get moved to next line ex.style, role, tabindex, aria-*, colspan

Format complex blade

It's really great to see a fresh new blade formatter eventually, I've been waiting for it for ages, thx for awesome job, man!
Btw, I have quite a complex case of blade code, no blade formatter could process on it correctly. But the code is working fine, however it's a bit ugly. Here it is.

<header class="face <?= isset($face_class) ? $face_class : '' ?>">
  <div class="container d-flex">
    @if (isset($face_class) && $face_class === 'face-narrow')
    <div class="col-md-7 face__wrapper">
      @else
      <div class="col-md-6 face__wrapper">
        @endif
        <h1 class="face__title">{{ $face_title }}</h1>
        @isset ($face_subtitle)
        <p class="face__subtitle">{{ $face_subtitle }}</p>
        @endisset
        @isset ($face_desc)
        <span class="face__text">{!! $face_desc !!}
          @endisset
          @isset ($face_desc_mb_hide)
          <span class="face__text d-none d-lg-inline">&ThinSpace;{!!
            $face_desc_mb_hide !!}</span>
          @endisset
        </span>
        @isset ($face_btn_text)
        <div class="face__button-box">
          <a href="{{ $face_anchor or '#request-form' }}" class="btn_regular"
            onclick="yaCounter.reachGoal('form'); return true;">{{ $face_btn_text }}</a>
          @endisset
          @isset ($clutch)
          <script type="text/javascript"
            src="https://widget.clutch.co/static/js/widget.js">
          </script>
          <div class="face__clutch clutch-widget"
            data-url="https://widget.clutch.co" data-widget-type="2"
            data-height="50" data-clutchcompany-id="861064"
            {{ $clutch === 'dark' ? 'data-darkbg="1"' : '' }}>
          </div>
          @endisset
          @isset ($face_btn_text)
        </div>
        @endisset
      </div>
      @if (isset($face_class) && $face_class === 'face-wide')
      <div class="col-md-7 face__image-box">
        @else
        <div class="col-md-7 col-lg-6 face__image-box">
          @endif
          @isset ($face_image)
          <picture>
            @isset ($face_image_webp)
            <source srcset="{{ $face_image_webp }}" type="image/webp">
            @endisset
            <img class="face__image" src="{{ $face_image }}" alt="Logo">
          </picture>
          @endisset
        </div>
      </div>
</header>

It'd be fantastic if your formatter can handle it someday. You can also notice an error /*escaped*/ after formatting the code.

Support for beautify.config

Supporting beautify.config would be great:

  "beautify.config": {
    "indent_size": 2,
    "wrap_line_length": 140,
    "wrap_attributes": "force-aligned"
  },

Then it's a perfect extension!

Error

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce

Context (Environment)

Detailed Description

Possible Implementation

No funciona el formateo en VSCode.

executing the command ALT + SHIFT + F shows the following message VS Code "Cannot invoke loadWASM more than once." and does not do any formatting.

The only thing I did was create a file "thing.blade.php" to start putting the internal structure of the file and when I wanted to format the code VS Code asked me to install a format for blade, so I looked for one and I found this and when I executed the command for format did nothing

error

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce

Context (Environment)

Detailed Description

Possible Implementation

error formater in function old()

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce

Context (Environment)

Detailed Description

Possible Implementation

Strips existing code

Tried this on a couple of blade templates and it stripped everything up to the first blade marker {{. One had some HTML first and the other was a mix of HTML and PHP.

issues

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

error

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

unwanted format

Template

** @{{ item.product }} **

** it become @{{ item . product }} **

  • write your environment
  • vs code
  • i am using vue.js inside blade
  • it will not add useless spaces before and after the dot (.) in echo-raw blade
  • it's hard to read

Description

Any other information

Doesn't work

Hi,

When I save my blade file, nothing happens.

Do we need to configure something ?

Thanks

php format

Hi there,

Would it be possible to format code between php directive (@php ... @endphp) with php formatter ?
sometimetimes usefull, exemple for a multi-array $template var in wordpress gutenberg block..
a bit hard to read when flated, as blade-formatter remove the "manual" indent/format on save.

{{--
  Title: Section featuredImg + 2cols
  Category: lalibellule
  Icon: admin-comments
  Keywords: section columns image
  Mode: preview
  SupportsMode: false
  SupportsMultiple: true
  SupportsInnerBlocks: true
--}}
@php
$template = [
[ 'core/columns', ['className' => 'l-SiteRow l-SiteRow--332'], [
['core/column', ['className' => 'l-SiteCol'], [
['cgb/block-fib']
]],
[ 'core/column', ['className' => 'l-SiteCol'],[
[ 'core/paragraph', [ 'placeholder' => 'Entrer du contenu...' ] ],
]],
[ 'core/column', ['className' => 'l-SiteCol'],[
[ 'core/paragraph', [ 'placeholder' => 'Entrer du contenu...' ] ],
]],
]]
];
@endphp

<section data-{{ $block['id'] }} class="l-SectionCols">
  <InnerBlocks template="<?= esc_attr( wp_json_encode($template)) ?>" />
</section>

Anyway, thank you for the best blade formatter out there !
Best.

Text colour changing to white

Template

Text colour is changing to white.

"indent_size": 4,
"wrap_line_length": 120,
"wrap_attributes": "auto"

Colour as provided by theme should be present.

Can not format blade: "Check if temp is too complicated or not"

Template


@extends('layouts/app')

@section('content')
    @if ($x)
        asdasd
    @endif
@endsection

Context (Environment)

Can't format blade: something goes wrong. Please check if template is too complicated or not. Or simplify template might solves issue.

  • write your environment

try to format

update1: it happens when I set the "bladeFormatter.format.wrapAttributes" to "force-expand-multiline",

update2: after a file formatted once, all attempts to format throws this error! no matter what is the wrapAttribute value

not properly work

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

Error formating blade

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

vscode error

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

Indent Type Support

Are there any plans to allow users to set indent size? Personally, I prefer tabs to spaces and the extension doesn't seem to inherit the file's preferred spacing method.

error in save

Template

memory allocation.

Context (Environment)

  • ubuntu 20
  • vscode 1.51.1

Description

Any other informations

Blade directives mixed in with script tags causes formatter to fail

Template

@push('scripts')
    <script src="{{ asset('backend/plugins/dropzone/dropzone.min.js') }}"></script>
    <script>
        Dropzone.options.gallery = {
            url: "...",
            previewTemplate: $("#preview-template").html(),
            dictDefaultMessage: "Drop files here or click to select",
            addRemoveLinks: true,
            uploadMultiple: true,
            maxFilesize: 2,
            filesizeBase: 1024,
            acceptedFiles: "image/jpg,image/jpeg,image/png",
            init: function () {
                this.renderExistingServerFiles = function(files, fileUrls , response){
                    for (const file in files) {
                        if (Object.hasOwnProperty.call(files, file)) {
                            const element = files[file];
                            
                            this.files.push(element);
                            this.displayExistingFile(element, fileUrls[file], null, null, true);
                            this.emit("processing", element);
                            this.emit("complete", element);
                        }
                    }
                    this.emit("successmultiple", files, response, false);
                }

                @isset($item->images)
                    let files = [];
                    let fileUrls = [];
                    let response = { status:"success", fileHashes: [], imageIds: []};
                    @foreach($item->images as $image)
                        @php
                            $imageUrl = asset('img/'.$image->image_hash);
                            $imagePath = public_path('img/'.$image->image_hash);
                            $imageMime = File::mimeType($imagePath);
                            $imageSize = File::size($imagePath);
                            $imageName = File::name($imagePath);
                        @endphp

                        files.push(
                            {
                                processing: true,
                                accepted: true,
                                name: "{{ $imageName }}",
                                size: {{ $imageSize }},
                                type: '{{ $imageMime }}',
                                status: Dropzone.SUCCESS,
                            },
                        );
                        
                        fileUrls.push("{{ $imageUrl }}")
                        response.fileHashes.push("{{ $image->image_hash }}")
                        response.imageIds.push("{{ $image->id }}")
                    @endforeach
                    this.renderExistingServerFiles(files, fileUrls, response);
                @endisset
            },
        }

    </script>
@endpush

Context (Environment)

  • Standard laravel dev environment

Tell me what should happen

The formatter should be able to format blade code inside script tags.

Description

Blade directives used inside java script tags causes issues with the formatter thereby causing it to fail.

fetch problams

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

Comments keep getting indented on every save or manual format trigger

Template

    <!--
                            Tailwind UI components require Tailwind CSS v1.8 and the @tailwindcss/ui plugin.
                            Read the documentation to get started: https://tailwindui.com/documentation
                            -->

Context (Environment)

OS: Windows 10
VSCode: 1.51.1
V-B-F: 0.6.1

Description

Every time I save, paste or manually apply formatting any comments are indented over and over beyond the 4-space setting.
Changing the "Wrap Attributes" setting does not have an effect.

Comments should only be indented once at the given space/tab setting.

    <!--
        Tailwind UI components require Tailwind CSS v1.8 and the @tailwindcss/ui plugin.
        Read the documentation to get started: https://tailwindui.com/documentation
        -->

Error "Cannot invoke loadWASM more than once." when saving blade file

Template

<div>
    <tr class="flex flex-col items-start md:table-row justify-center mb-10
        sm:hover:bg-gray-100">
        <td class="whitespace-no-wrap w-full">
            <div class="bg-blue-100 inline-block py-1 px-2 text-xs md:hidden rounded">Title</div>
            <div class="items-center py-3 px-6">
                <div class="text-sm font-medium text-gray-900">
                    {{ $vacancy->title }}
                </div>
            </div>
        </td>
        <td class="whitespace-now-rap w-full">
            <div class="bg-blue-100 inline-block py-1 px-2 text-xs md:hidden rounded">Status</div>
            <div class="items-center py-3 px-6">
                <x-badges.error>Disabled</x-badges.error>
            </div>
        </td>
        <td class="whitespace-no-wrap w-full">
            <div class="bg-blue-100 inline-block py-1 px-2 text-xs md:hidden rounded">Subscription period</div>
            <div class="items-center py-3 px-6">
                <div class="text-sm font-medium text-gray-900 whitespace-nowrap">
                    @empty($vacancy->subscription)
                        No subscription
                    @else
                        {{ $vacancy->subscription }}
                    @endempty
                </div>
            </div>
        </td>
        <td class="whitespace-no-wrap w-full">
            <div class="bg-blue-100 inline-block py-1 px-2 text-xs md:hidden rounded">Created At</div>
            <div class="items-center py-3 px-6">
                <div class="text-sm font-medium text-gray-900 whitespace-nowrap">
                    {{ $vacancy->created_at->format('d.m.Y h:i:s') }}
                </div>
            </div>
        </td>
        <td class="flex px-6 py-2 md:py-4 w-full bg-gray-100 md:bg-transparent justify-evenly">

            <button wire:click="cloneVacancy({{ $vacancy->id }})" class="inline-block cursor-pointer p-1 border border-transparent transition duration-500 ease-in-out hover:border-green-400 text-green-500 rounded mr-2 focus:bg-green-400 focus:outline-none focus:text-white" title="Clone vacancy">
                <svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
                </svg>
            </button>

            <button wire:click="redirectToVacancyEditForm" class="inline-block cursor-pointer p-1 text-indigo-500 focus:text-white focus:outline-none focus:bg-indigo-400 border border-transparent transition duration-500 ease-in-out hover:border-indigo-400 rounded mr-2" title="Edit vacancy">
                <svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
                    stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
                </svg>
            </button>

            @if ($confirmDelete == $vacancy->id)
                <button wire:click="removeVacancy" class="inline-block cursor-pointer text-white bg-red-400 focus:text-red-400 focus:border-red-400 focus:outline-none focus:bg-transparent py-1 px-2 border border-red-400 transition duration-500 ease-in-out text-base font-semibold hover:border-red-500 hover:bg-red-500 rounded" title="Confirm delete">
                    Sure?
                </button>
            @else
                <button wire:click="$emitUp('confirmVacancyDelete', {{ $vacancy->id }})" class="inline-block cursor-pointer text-red-500 focus:text-white focus:outline-none focus:bg-red-400 p-1 border border-transparent transition duration-500 ease-in-out hover:border-red-400 rounded" title="Delete vacancy">
                    <svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            @endif
        </td>
    </tr>
</div>

Context (Environment)

Environment: Development

Description

When saving the item.blade.php file I get the error "Cannot invoke loadWASM more than once". I use Laravel 8 with Jetstream.

formation Erro

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

Blade não está formatando

Template

Please write your blade template that occurs issues.

Context (Environment)

  • write your environment

Description

Any other informations

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.