pug-php / pug

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

Fatal error on variable name "comment" #113

Closed fffixed closed 7 years ago

fffixed commented 7 years ago

If I use anywhere:

{vars.comment}

I have Fatal error!


'expressionLanguage' => 'js'

kylekatarnls commented 7 years ago

This syntax is deprecated in pugjs 2, and we will also drop it on the next major version: https://pugjs.org/api/migration-v2.html#attribute-interpolation

We implemented it in expression php/auto but it is not yet implemented js syntax in interpolation. I'm currently focused on the next major version that will use a new engine: https://github.com/phug-php made with @TorbenKoehn, the developer of tale-jade to provide a unique and reliable engine compliant with pugjs 2.0.

After that I could do this fix for those who won't upgrade.

For now I have not time enough but I would be happy to merge pull-requests for this if anyone would help.

But my main recommendation remains: do not use this syntax since pugjs 2 dropped it.

fffixed commented 7 years ago

Sorry, this syntax is deprecated only for "Attribute Interpolation", not for "String Interpolation". And it works well till using word "comment" in variable's name. Please try this:

<?php
require_once '../vendor-php/autoload.php';
$pug = new Pug\Pug(array(
  'expressionLanguage' => 'js',
  'prettyprint' => true
  ));

$output = $pug->render("p fatal paragraf #{vars.comment}");
echo $output;

And this ok: $pug->render("p= vars['comment']"); this ok: $pug->render("p= vars.nocomment"); this error: $pug->render("p= vars.comment");

kylekatarnls commented 7 years ago

Oh great, this is a good news because this is not about interpolation, it's a regression in js-phpize. And as it only seems to be a specific problem with comment, it should be fast to find.

kylekatarnls commented 7 years ago

Hi, please use composer update to get js-phpize version 1.3.0. It should works since the following is OK in the compiler demo:

p #{vars.comment}
fffixed commented 7 years ago

Wow! It's cool! Thank You!