phug-php / phug

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

Parser breaks after html tag #34

Closed grieverrr closed 6 years ago

grieverrr commented 6 years ago

Hello,

I encountered an issue with the following code:

div.grid.pg-header__grid
  div.pg-header__top
  <span>test</span>
    div.pg-header__city

I expected to get:

<div class="grid pg-header__grid">
  <div class="pg-header__top"><span>test</span>
    <div class="pg-header__city"></div>
  </div>
</div>

But I actually get:

<div class="grid pg-header__grid">
  <div class="pg-header__top"><span>test</span>
    div.pg-header__city
</div>
</div>

Thanks!

kylekatarnls commented 6 years ago

It's the expected behavior:

<p>
  Indented text is raw text
</p>

However the following is expected to get what you want:

div.grid.pg-header__grid
  div.pg-header__top
    <span>test</span>
    div.pg-header__city

Note that however Must be indented, else it's not inside pg-header__top.

I will inspect.

kylekatarnls commented 6 years ago

Right now, I have only this as work-around:

div.grid.pg-header__grid
  div.pg-header__top
    | <span>test</span>
    div.pg-header__city
grieverrr commented 6 years ago

It is not really problem, but the thing is confusing is that the pugjs have different behavior in this case

kylekatarnls commented 6 years ago

I finally aligned this behavior on pugjs. You can test the next release of the lexer by running composer require phug/lexer=dev-master (need a dev minimum stability), or you can cheat your composer.json to not change the minimum stability:

    "require": {
        "phug/lexer": "dev-master as 0.5.999",
    },

When I will tag it as official release and test it via other project you'll be able to remove the lexer from your dependencies.

kylekatarnls commented 6 years ago

Fixed in lexer 0.5.27