phug-php / phug

Phug - The Pug Template Engine for PHP
https://phug.selfbuild.fr
MIT License
63 stars 3 forks source link

Closing tag not indented when rendering using `pretty` option on some case #15

Closed char101 closed 6 years ago

char101 commented 6 years ago

Hello,

I encountered an issue with the following code:

doctype html

mixin test
  a item1
  a item2

html
  head
  body
    .div1
      .div2
        +test
        .div21
          +test
      .div3

I expected to get:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <div class="div1">
      <div class="div2"><a>item1</a><a>item2</a>
        <div class="div21"><a>item1</a><a>item2</a></div>
      </div>
      <div class="div3"></div>
    </div>
  </body>
</html>

But I actually get:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <div class="div1">
      <div class="div2"><a>item1</a><a>item2</a>        <div class="div21"><a>item1</a><a>item2</a></div>
</div>
      <div class="div3"></div>
    </div>
  </body>
</html>

Thanks!

char101 commented 6 years ago

pugjs output

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <div class="div1">
      <div class="div2"><a>item1</a><a>item2</a>
        <div class="div21"><a>item1</a><a>item2</a>
        </div>
      </div>
      <div class="div3"></div>
    </div>
  </body>
</html>
kylekatarnls commented 6 years ago

For both Pugjs and Phug, pretty is a deprecated and not 100% reliable option. I recommand to better use a separated HTML beautifier. Moreover, mixins are executed at render time, and indent them according to the call indent would cost a lot. We probably won't fix this.

char101 commented 6 years ago

Thanks for the explanation, I'll try to format the resulting HTML using tidy5.