Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap align html attributes only when line reaches certain length #1262

Open
asolopovas opened this issue Sep 27, 2017 · 8 comments
Open

Wrap align html attributes only when line reaches certain length #1262

asolopovas opened this issue Sep 27, 2017 · 8 comments

Comments

@asolopovas
Copy link

Is it possible to only wrap html attributes when line reaches certain length of characters. The way it works in Phpstorm for example is that If I have something like this.

<div v-for="item in items" class="items">
    <p>{{item.name}}</p>
</div>

Phpstorm formatter does not wrap the attributes but if my code looks something like this

<div v-for="item in items" class="items" v-if="items.notEmpty()" :class="{active: isActive} :key="item.id">
    <p>{{item.name}}</p>
</div>

and line contains more then 100 characters then it will wrap the attributes and align them like so

<div v-for="item in items" 
     class="items" 
     v-if="items.notEmpty()" 
     :class="{active: isActive} 
     :key="item.id">
    <p>{{item.name}}</p>
</div>
@asolopovas asolopovas changed the title Wrap align html attributes when they rich certain amount of characters Wrap align html attributes only when line reaches certain length Sep 27, 2017
@bitwiseman
Copy link
Member

See #1125 for related discussion. Not exactly the same feature, but related.

@RenaldasK
Copy link

Is this getting implemented? It's very annoying when the following:
<meta content="IE=edge" http-equiv="X-UA-Compatible">

becomes:

<meta content="IE=edge"
      http-equiv="X-UA-Compatible">

Even though there's plenty of space to keep it in one line

@bitwiseman
Copy link
Member

@RenaldasK
This issue is unassigned. It needs someone to implement a fix and tests, submit a PR, and drive it to completion. Perhaps you?

@NEO97online
Copy link

+1, this is exactly how we would expect the behavior to work

@RenaldasK
Copy link

I might take a look it this weekend. Should this be implemented under --wrap-attributes auto or some new option?

@RenaldasK
Copy link

Actually I had a look at #1285 issue and the behaviour described there suits my needs as well, so I think I might fork this PR #1297 instead and try to get it merged and closed.

@Adondriel
Copy link

I was thinking an option for something like a "number of attributes before wrapping" would be nice, so I could say, anything with < 4 attributes won't be wrapped, while anything >= 4 attributes would be wrapped, and that would be configurable per user, of course.

@vvs
Copy link

vvs commented Jun 13, 2018

@Adondriel This is tricky. One attribute could be just 3-5 characters long, another one can be 50 chars. Wrapping by default should deal with lengths, not with number of attributes, but it is an interesting additional option to consider...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants