shufo / blade-formatter

An opinionated blade template formatter for Laravel that respects readability
https://www.npmjs.com/package/blade-formatter
MIT License
456 stars 25 forks source link

[Feature Request] `--extra_liners` option #842

Closed shufo closed 1 year ago

shufo commented 1 year ago

Ref:

  -E, --extra_liners                 List of tags (defaults to [head,body,/html] that should have an extra newline before them.

Source (index.html)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <p>Dummy</p>
  </body>
</html>

-I option

npx js-beautify -I index.html

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>

    <body>
        <p>Dummy</p>
    </body>

</html>

[Feature Request] add -E option

npx js-beautify -I -E= index.html

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <p>Dummy</p>
    </body>
</html>

Originally posted by @yaegassy in https://github.com/shufo/blade-formatter/issues/840#issuecomment-1650634111

ldommer commented 1 year ago

@shufo

I think I wrote an email to you some months ago, asking for this feature.

Today I reached out for your plugin again and made it a file watcher in my PhpStorm settings.

I remembered missing this feature, forked your repo and added this functionality as an option for your Blade Formatter, modifying the behaviour of html-beautify with the extra liners option as array.

I already pushed my feature branch and linked this issue in my pull request.

yaegassy commented 1 year ago

@shufo @ldommer Thanks for adding the feature. I checked in my environment and confirmed the expected behavior.