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.format.wrapAttributes on handlebars template #1199

Closed
aeschli opened this issue May 26, 2017 · 5 comments
Closed

html.format.wrapAttributes on handlebars template #1199

aeschli opened this issue May 26, 2017 · 5 comments

Comments

@aeschli
Copy link

aeschli commented May 26, 2017

From @ifahrentholz on May 25, 2017 13:41

  • VSCode Version: 1.12.2
  • OS Version: OSX 10.11.6 (15G1217) (El Capitan)

Steps to Reproduce:

  1. I've set the following settings:
"html.format.wrapLineLength": 0,
"html.format.wrapAttributes": "force-aligned",
"editor.wordWrap": "off",
"editor.wrappingIndent": "same",
"window.zoomLevel": 0,
  1. Use the following markup:
<input type="radio"
       name="garage"
       id="garage-02"
       class="ns-e-togg__radio ns-js-form-binding"
       value="02"
       {{#ifCond data.antragsart "05"}}
       checked="checked"
       {{/ifCond}}>
  1. Hit save and VSCode will break the ifCond statement on new lines - which causes a code bug.

wrapattributes

Copied from original issue: microsoft/vscode#27272

@bitwiseman
Copy link
Member

@aeschli
That gif is very pretty, but I could you provide just the resulting text output instead? The difference from the input will be just as visible and easier to work with. 😄

@ifahrentholz
Copy link

ifahrentholz commented May 31, 2017

Resulting text output:

<input type="radio"
       name="garage"
       id="garage-02"
       class="ns-e-togg__radio ns-js-form-binding"
       value="02"
       {{#ifCond
       data.antragsart
       "05"}}
       checked="checked"
       {{/ifCond}}>

@ifahrentholz
Copy link

ifahrentholz commented Sep 24, 2017

I've discovered an similar issue on HTML templates which are used for Assemble-Templates.

Before formatting (correct):

---
layout: mainLayout.html
page: default.html
---

<div>
    {{> componentXYZ my.data.key}}
    {{> componentABC my.other.data.key}}
    <span>Hello World</span>
    <p>Your paragraph</p>
</div>

After formatting (wrong):

--- layout: mainLayout.html page: default.html ---

<div>
    {{> componentXYZ my.data.key}} {{> componentABC my.other.data.key}}
    <span>Hello World</span>
    <p>Your paragraph</p>
</div>

I think an applicable solution would be that the formatter ignores elements it does not know completely - i think thats the way other Editors handle that case (tested on Webstorm / Intellij IDEA).

@brokenalarms
Copy link

Just led here by trying to find why js-beautify breaks hbs files when you're just trying to preserve all your newlines but get correct indenting... +1!

@MacKLess
Copy link
Collaborator

I just ran this in v1.8.0-rc14 and the actual output is unchanged from the input. I'm assuming this is the correct formatting. @ifahrentholz and @aeschli please let me know if this issue requires further attention.

Just for reference, here is the actual output for the second given example:

---
layout: mainLayout.html
page: default.html
---

<div>
    {{> componentXYZ my.data.key}}
    {{> componentABC my.other.data.key}}
    <span>Hello World</span>
    <p>Your paragraph</p>
</div>

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

5 participants