pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
391 stars 42 forks source link

syntax error, unexpected ';', expecting ',' or ')' #193

Closed sandrodz closed 6 years ago

sandrodz commented 6 years ago

Hello,

I encountered an issue with the following code:

          each v, i in {'fb': 'facebook', 'tw':'twitter','yt':'youtube','li':'linkedin'}
            a(
              href=href[i]
              class="bg-w bsh-5 bdR-r c-p c:h-s ml-xxs"
              style="width:5rem; height:5rem; padding: 0.5rem")
              div(class="g g--alignCenter g--spaceCenter bd-s w-1/1 h-f bdR-r")
                i(class="i i--"+v+" fz-22")

this seems to be a culprit: href=href[i]

Thanks!

kylekatarnls commented 6 years ago

Confirmed, it works in this order however:

each v, i in {'fb': 'facebook', 'tw':'twitter','yt':'youtube','li':'linkedin'}
  a(
    class="bg-w bsh-5 bdR-r c-p c:h-s ml-xxs"
    style="width:5rem; height:5rem; padding: 0.5rem"
    href=href[i])
    div(class="g g--alignCenter g--spaceCenter bd-s w-1/1 h-f bdR-r")
      i(class="i i--"+v+" fz-22")

And it works with a trailing coma:

each v, i in {'fb': 'facebook', 'tw':'twitter','yt':'youtube','li':'linkedin'}
  a(
    href=href[i],
    class="bg-w bsh-5 bdR-r c-p c:h-s ml-xxs"
    style="width:5rem; height:5rem; padding: 0.5rem")
    div(class="g g--alignCenter g--spaceCenter bd-s w-1/1 h-f bdR-r")
      i(class="i i--"+v+" fz-22")

Some expressions are tricky to mark out, the coma as attribute delimiter ensure there is no possible ambiguity.

kylekatarnls commented 6 years ago

Hi, the new lexer (0.5.23) will detect ] as a value wrapper so if you update (composer update), you should be able to get your first syntax working. If not, please let me know and I'll re-open.