shufo / prettier-plugin-blade

Format your blade template using Prettier
https://www.npmjs.com/package/@shufo/prettier-plugin-blade
MIT License
316 stars 8 forks source link

[Formatting Bug]: Incorrect formatting #268

Closed ONyklicek closed 1 month ago

ONyklicek commented 4 months ago

Version

2.0.0

Template before formatting

<x-mail::message>
    {{-- Subcopy --}}
    @isset($actionText)
        <x-slot:subcopy>
            @lang(
                        "If you're having trouble clicking the \":actionText\" button, copy and paste the URL below\n".
                        'into your web browser:',
                        [
                            'actionText' => $actionText,
                        ]
                    )
            <span class="break-all">[{{ $displayableActionUrl }}]({{ $actionUrl }})</span>
        </x-slot:subcopy>
    @endisset
</x-mail::message>

Template after formatting

<x-mail::message>
    {{-- Subcopy --}}
    @isset($actionText)
        <x-slot:subcopy>
            @lang(
                        "If you're having trouble clicking the \":actionText\" button, copy and paste the URL below\n".
                        'into your web browser:',
                        [
                            'actionText' => $actionText,
                        ]
                    )
            <span class="break-all">[{{ $displayableActionUrl }}]({{ $actionUrl }})</span>
        </x-slot>
    @endisset
</x-mail::message>

Expected Behaviour

Tag should not be edited. When using ignore tags, the code is still refactored. Used in PHPStorm.

.prettierrc

{
    "singleQuote": true,
    "trailingComma": "all",
    "printWidth": 240,
    "tabWidth": 4,
    "endOfLine": "lf",
    "plugins": [
        "prettier-plugin-antlers",
        "prettier-plugin-blade",
        "@prettier/plugin-php",
        "prettier-plugin-tailwindcss"
    ],
    "overrides": [
        {
            "files": "**/*.php",
            "options": {
                "parser": "php",
                "singleQuote": false,
                "phpVersion": "8.2"
            }
        },
        {
            "files": "*.blade.php",
            "options": {
                "parser": "blade",
                "singleQuote": false,
            }
        },
        {
            "files": [
                "**/*.css",
                "**/*.html"
            ],
            "options": {
                "singleQuote": false
            }
        }
    ]
}

Relevant log output

No response

benbjurstrom commented 3 months ago

Having the same issue. I know that technically the closing tag doesn't need the slot name. But PHPstorm complains that the tags don't match if it's missing. Using ignore tags to prevent this don't work for me either.

ONyklicek commented 3 months ago

Having the same issue. I know that technically the closing tag doesn't need the slot name. But PHPstorm complains that the tags don't match if it's missing. Using ignore tags to prevent this don't work for me either.

When using <x-slot:subcopy> it is advisable to close them in the same way. In my case the template for mail notifi was corrupted.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days