blade-formatter icon indicating copy to clipboard operation
blade-formatter copied to clipboard

Setting that would ignore formatting on specific tags, i.e. <svg> ?

Open yabdab opened this issue 3 years ago • 10 comments

Formatting things like a <svg> tag can take up several lines of code and is not really that necessary.

Now this plugin does an excellent job formatting it, but it adds tons of new lines to my code.

This is just a feature request to allow a setting that ignores certain tags if not too much trouble?

I know I can use {{-- blade-formatter-disable-next-line --}} , but this would be easier if possible 😉

Thanks guys.

yabdab avatar Sep 22 '22 10:09 yabdab

Thanks for requesting the feature @yabdab

it adds tons of new lines to my code.

From my understand, you are talking about like below code with --wrap-attributes option is set to force-expand-multiline?

$ cat test.blade.php
<svg height="130" width="500">
  <defs>
    <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
      <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />
      <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
    </linearGradient>
  </defs>
  <ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#grad1)" />
  <text fill="#ffffff" font-size="45" font-family="Verdana" x="50" y="86">SVG</text>
  Sorry, your browser does not support inline SVG.
</svg>
  $  ./bin/blade-formatter test.blade.php --wrap-attributes force-expand-multiline

<svg
    height="130"
    width="500"
>
    <defs>
        <linearGradient
            id="grad1"
            x1="0%"
            y1="0%"
            x2="100%"
            y2="0%"
        >
            <stop
                offset="0%"
                style="stop-color:rgb(255,255,0);stop-opacity:1"
            />
            <stop
                offset="100%"
                style="stop-color:rgb(255,0,0);stop-opacity:1"
            />
        </linearGradient>
    </defs>
    <ellipse
        cx="100"
        cy="70"
        rx="85"
        ry="55"
        fill="url(#grad1)"
    />
    <text
        fill="#ffffff"
        font-size="45"
        font-family="Verdana"
        x="50"
        y="86"
    >SVG</text>
    Sorry, your browser does not support inline SVG.
</svg>


I agree that it would be a lot of lines.

My personal recommendation is if you are concerned about lines of code, split them into Anonymous Components would be a good solution.

However, I understand that there are some use cases where it is more convenient to ignore certain tags, so I'll give some thought to what we should do.

shufo avatar Sep 25 '22 10:09 shufo

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

github-actions[bot] avatar Dec 05 '22 01:12 github-actions[bot]

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

github-actions[bot] avatar Feb 14 '23 02:02 github-actions[bot]

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

github-actions[bot] avatar Apr 24 '23 01:04 github-actions[bot]

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

github-actions[bot] avatar Aug 12 '23 01:08 github-actions[bot]

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

github-actions[bot] avatar Oct 12 '23 01:10 github-actions[bot]

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

github-actions[bot] avatar Dec 12 '23 01:12 github-actions[bot]

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

github-actions[bot] avatar Mar 01 '24 01:03 github-actions[bot]

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

github-actions[bot] avatar May 08 '24 01:05 github-actions[bot]