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

How to prevent attribute wrapping? #67

Open
kareljan opened this issue Oct 6, 2020 · 7 comments
Open

How to prevent attribute wrapping? #67

kareljan opened this issue Oct 6, 2020 · 7 comments

Comments

@kareljan
Copy link

kareljan commented Oct 6, 2020

How can I prevent the attributes to wrap to new lines?

<div class="fancy-stuff" id="element{{ loop.index }}">
gets

<div class="fancy-stuff"
          id="element{{ loop.index }}">

I don't want the ID to wrap to a new line.

@kareljan
Copy link
Author

anyone?

@mubaraqwahab
Copy link

You can use {# prettier-ignore #} above that line.

@kareljan
Copy link
Author

That's not an option. I want to disable it for the entire file. It puts every attribute of every line on new lines. If I put prettier-ignore on the entire file,the purpose of prettier is gone.

@mubaraqwahab
Copy link

I tried the snippet isolated and it didn't break (with the default proseWidth). When it's nested however:

<div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div>
                    <div>
                      <div class="fancy-stuff" id="element{{ loop.index }}"></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

It breaks like you have mentioned:

<div class="fancy-stuff"
  id="element{{ loop.index }}"></div>

I'm assuming you have something like this.

Prettier's own HTML formatter pretty prints it when it's nested deeply like so:

<div
  class="fancy-stuff"
  id="element{{ loop.index }}"
></div>

If you would prefer Prettier's own formatting, I wrote a plugin for this Twig plugin that you can check out: prettier-plugin-twig-enhancements

@kareljan
Copy link
Author

kareljan commented Nov 3, 2020

No I just want to keep all attributes on one line like so

<div class="fancy-stuff" id="element{{ loop.index }}">

@mubaraqwahab
Copy link

Sorry I don't know how then.

@kareljan
Copy link
Author

anyone?

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

No branches or pull requests

2 participants