Js-beautify: Sorting of HTML attributes

Created on 22 Feb 2018  路  6Comments  路  Source: beautify-web/js-beautify

Description

Is there anyway to enable sorting of HTML attributes?

Input

<input class="input is-small"
            type="text"
            v-model="domainFilter"
            placeholder="search">

Expected Output

The code should have looked like this after beautification:

<input class="input is-small"
            placeholder="search"
            type="text"
            v-model="domainFilter">

Actual Output

The code actually looked like this after beautification:

<input class="input is-small"
            type="text"
            v-model="domainFilter"
            placeholder="search">

Steps to Reproduce

Just add some attributes

Environment

OS: Windows 10
Vs-Code Latest

Settings

{
    "editorconfig": true,
      "indent_size": 2,
      "wrap_attributes": "force-aligned",
      "wrap_attributes_indent_size": 2,
      "wrap_line_length": 80
}
html enhancement

Most helpful comment

Html now tokenizes before formatting. This mean it would be much easier to implement this now if any one wants to.

All 6 comments

Beautifier doesn't currently reorder content.

Html now tokenizes before formatting. This mean it would be much easier to implement this now if any one wants to.

It would be great to see support for this. I like to keep my attributes alphabetically ordered - it helps me finding the attributes faster. (This issue is, at least to me, somewhat related to #1084, which is about re-ordering CSS properties alphabetically.)

Would be very handy for diffing

any update for this? Hope this feature could be supported soon, thanks !

@pianoboysai
PRs welcome! Please contribute!

Was this page helpful?
0 / 5 - 0 ratings