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

HTML: add an option to preserve manual wrapping of attributes #1125

Closed
Andikki opened this issue Feb 4, 2017 · 19 comments
Closed

HTML: add an option to preserve manual wrapping of attributes #1125

Andikki opened this issue Feb 4, 2017 · 19 comments

Comments

@Andikki
Copy link

Andikki commented Feb 4, 2017

--wrap-attributes option has these possible values: auto|force|force-aligned|force-expand-multiline
This allows to whether condense all attributes into one line or auto-wrap each of them.

Would it be possible to just maintain the initial wrapping?

@Robula
Copy link

Robula commented Feb 16, 2017

This is a great idea, none of the options allow for wrapping manually.

It would be great to have an option that would perform force|force-aligned|force-expand-multiline only if the wrap line length (default 120) has been hit as auto wraps only as many attributes as it needs to. Something like auto-expand-multiline|auto-aligned options?

@bitwiseman
Copy link
Member

@Robula
Please open a new issue for what you have in your second paragraph.

@bitwiseman
Copy link
Member

@Montago, @Andikki - what you are describing is an option named something like unchanged or preserve, correct?

@Montago
Copy link

Montago commented Jun 9, 2017

@bitwiseman no, just another option like "Force-Aligned" ... but instead "auto-aligned"

What it should do, is simply to align all attributes that have been manually wrapped.
all other elements / attributes are untouched.

@bitwiseman
Copy link
Member

@Montago - Ah, so more like align-only.

@Montago
Copy link

Montago commented Jun 10, 2017

yeah that makes sense :)

@roderickfung
Copy link

bump for this!

@neilshah2000
Copy link

Would be great to manually have some attributes on a new line and some on the same line. Then i can decide which one i want and everything else is automatically formatted. Thanks

@Andikki
Copy link
Author

Andikki commented Sep 11, 2017

@bitwiseman I don't think aligning is necessary, but if it is, there have to be two options - one to apply the usual indent_size, another to align — all while keeping the initial line breaks.

Example
Source:

<input type="text"     class="form-control"  autocomplete="off" 
      [(ngModel)]="myValue"          [disabled]="isDisabled" [placeholder]="placeholder" 
  [typeahead]="suggestionsSource" [typeaheadOptionField]="suggestionValueField" [typeaheadItemTemplate]="suggestionTemplate"   [typeaheadWaitMs]="300"
                        (typeaheadOnSelect)="onSuggestionSelected($event)" />

Forcing indentation only:

<input type="text" class="form-control" autocomplete="off" 
  [(ngModel)]="myValue" [disabled]="isDisabled" [placeholder]="placeholder" 
  [typeahead]="suggestionsSource" [typeaheadOptionField]="suggestionValueField" [typeaheadItemTemplate]="suggestionTemplate" [typeaheadWaitMs]="300"
  (typeaheadOnSelect)="onSuggestionSelected($event)" />

Forcing alignment only:

<input type="text" class="form-control" autocomplete="off" 
       [(ngModel)]="myValue" [disabled]="isDisabled" [placeholder]="placeholder" 
       [typeahead]="suggestionsSource" [typeaheadOptionField]="suggestionValueField" [typeaheadItemTemplate]="suggestionTemplate" [typeaheadWaitMs]="300"
       (typeaheadOnSelect)="onSuggestionSelected($event)" />

@waldnercharles
Copy link

waldnercharles commented Oct 3, 2017

Not sure if this is the right issue to request this, but I feel like an auto-align option should act like auto; wrapping after a certain column cutoff, and if a line wraps, it treats the tag like force-align.

Example
Force-align when line length is greater than wrapLineLength:

<div [isWrapped]="false" [attributesAligned]="false"></div>

<really-long-angular-component-that-would-force-wrapping class="wrapped"
                                                         [isWrapped]="true"
                                                         [attributesAligned]="true">

@kaankucukx
Copy link

Almost surfed 5 or 6 topics where people looking forward to this feature to be implemented. Since its not, it would be great to have this on vscode with if wrap requries and force-alignment for this corresponding row vs.

😞

@bitwiseman
Copy link
Member

@kaankucukx Not sure what you mean? Is it covered in previous examples?

@brokenalarms
Copy link

brokenalarms commented Apr 2, 2018

+1 for this, I currently have the best results with force for handlebars, but it still results in unwanted wrapping within my handlebars block:

   </label>
     {{#artdeco-hoverable-trigger placement="right"
      as
      |card|}}

and

  <ul class="text-ad-edit-panel__dropdown-list">
    {{#each yourCompanyPageTypes
      as
      |companyPageType
      index|}}

I just need to preserve the newlines of manually newlined attributes, but get the correct indentation.

@RobbieTheWagner
Copy link

FWIW this does not work in any editor, that I have found, except for Intellij. Would love to see this implemented though!

@aimitservicesdev
Copy link

FWIW this does not work in any editor, that I have found, except for Intellij. Would love to see this implemented though!

Works in Netbeans as well.

@christoferd
Copy link

FWIW cannot get this working in VSCode
Developing wit Vue
Extensions: Prettier, Vetur
Formatting keeps reverting all html tags and attributes to one line. I've tread plenty of suggested solutions.
Would be great to know if people have this working within a .vue file in VSCode

@RobbieTheWagner
Copy link

@christoferd that's what this issue is about. It does not work. js-beautify is not capable of keeping the line breaks. It's going to always set it to one line.

I keep going back to using WebStorm because they have their own formatter and it works with line breaks.

@bitwiseman bitwiseman added this to the v1.8.x milestone Sep 30, 2018
@MacKLess
Copy link
Collaborator

MacKLess commented Oct 1, 2018

Related to #1404

@RobbieTheWagner
Copy link

Thanks for working on a fix @MacKLess! I'm anxiously awaiting a new release, so I can try it out 😃

@bitwiseman bitwiseman modified the milestones: v1.8.x, v1.8.7 Oct 12, 2018
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