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

Allow one blank line between elements at the same level #43

Closed
gertqin opened this issue Oct 14, 2018 · 4 comments
Closed

Allow one blank line between elements at the same level #43

gertqin opened this issue Oct 14, 2018 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers proposal

Comments

@gertqin
Copy link

gertqin commented Oct 14, 2018

🚀 Feature Proposal

Like prettier allows one blank line between statements in the same scope, prettyhtml could also allow one blank line between elements at the same level (potentially as a configuration option).

Motivation

It can improve readability of long html.

Example

This would then be allowed:

<div>
  <div class="header">
    <h1>Title...</h1>
  </div>

  <div class="content">
     <p>paragraph...</p>
  </div>
</div>

where as

<div>

  <div class="header">...</div>



  <div class="content">...</div>

</div>

should become

<div>
  <div class="header">...</div>

  <div class="content">...</div>
</div>
@StarpTech
Copy link
Member

Hi @gertqin thank you for your proposal. I agree that it could help for some scenarios but I'm not convinced. Can you show me some real examples? Can you link me to the prettier option?

@StarpTech StarpTech added enhancement New feature or request proposal labels Oct 14, 2018
@gertqin
Copy link
Author

gertqin commented Oct 14, 2018

Hi @StarpTech, thanks for considering the proposal :)

While I agree with you, that if you can keep your html components small enough this would not be needed. But in bigger applications this can be hard to achieve.

As an example here is (a bit simplified) vue component from one of my projects:

<div class="smart-table">
  <div class="smart-table-header">
    <slot name="header"/>
  </div>
  
  <template v-for="item in items">
    <div class="smart-table-item" :key="item.id">
      <slot name="item" :item="item"/>
    </div>
    <transition name="slide-down">
      <div v-if="isItemSelected(item)" class="smart-table-foldout">
        <slot name="foldout" :item="item" />
      </div>
    </transition>
  </template>

  <div class="smart-table-placeholder">
    <slot name="placeholder"></slot>
  </div>
</div>

Here the blank lines separates the header, item and placeholder sections, which I think makes the component more readable.

As for prettier, it is not an option - it is just part of their "rationale": https://prettier.io/docs/en/rationale.html#empty-lines

@StarpTech
Copy link
Member

@gertqin I'm fine with your proposal. Would you mind to a create a PR?

@StarpTech StarpTech added the good first issue Good for newcomers label Oct 19, 2018
StarpTech pushed a commit that referenced this issue Oct 28, 2018
Hi :)

I tried to get a stab at #43

I'm really not sure it's done the best it could be, but it sounds decent.
If you think of a better way, or at least better names, please tell me.

I didn't know if you wanted this feature behind an option. It's still possible.
@StarpTech
Copy link
Member

Fixed in #58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers proposal
Projects
None yet
Development

No branches or pull requests

2 participants