pug-php / pug

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

Ternary conditional operator should be defined inside brackets #207

Closed radiocity closed 6 years ago

radiocity commented 6 years ago

Hello,

I encountered an issue with the following code:

a.footer-group-link(
  href = row.url,
  target = row.is_blank ? '_blank' : null,
  rel = row.nofollow ? 'nofollow' : null,
) !{row.title}

I expected to get a link tag with optional attributes

But I actually get:

ErrorException [ Parse Error ]: syntax error, unexpected ')'
/www/vendor/phug/renderer/src/Phug/Renderer/Adapter/EvalAdapter.php(12) : eval()'d code [ 2128 ]

pug-php/pug requires ternary conditional operator to be defined inside brackets, but pugjs ignores brackets at all. So, following code would work with both libraries:

a.footer-group-link(
  href = row.url,
  target = (row.is_blank ? '_blank' : null),
  rel = (row.nofollow ? 'nofollow' : null),
) !{row.title}

Thanks!

kylekatarnls commented 6 years ago

Fixed via phug/lexer 0.5.29, you can run composer update to get it working without brackets.