phug-php / phug

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

Bug in parser #39

Closed AlexanderGogolev closed 5 years ago

AlexanderGogolev commented 5 years ago

Hello,

I encountered an issue with the following code:

body
  if (test == true)
    h1 Phug
  else
    <!---->
  div test

I expected to get:

<body>
  <h1>Phug</h1>
  <div>test</div>
</body>

But I actually get:

<body>
  <h1>Phug</h1>
</body>

Thanks!

AlexanderGogolev commented 5 years ago

this code work in pug.js

AlexanderGogolev commented 5 years ago

this work in version 2.7.5

kylekatarnls commented 5 years ago

Hi, I will check if we should handle this. The < mark RAW string output start.

But in any case, you should prefer:

body
  if (test == true)
    h1 Phug
  else
    //
  div test

for comments;

and:

body
  if (test == true)
    h1 Phug
  else
    | <!---->
  div test

for unescaped one-line string output. Both will work around the bug you get.

AlexanderGogolev commented 5 years ago

Thank )

kylekatarnls commented 5 years ago

Fixed, you can run composer update to get the new lexer version.