pug-php / pug

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

Can't use block unbuffered code with Pug PHP #97

Closed esiao closed 7 years ago

esiao commented 7 years ago

pug offers a nice way to do tests, assign variables... within a pug template by using the unbuffered code block style. See: https://pugjs.org/language/code.html#unbuffered-code

With pug-php it's not possible, as the Parser crashes with Unexpected token "indent" error. Would it be possible to implement? Saying that using this syntax would actually be executed as a php block with the current scope. Would love to see this feature coming to pug-php.

Thanks.

kylekatarnls commented 7 years ago

Hi, next major version with allow this syntax. I hope you can wait until this release. It could take time.

esiao commented 7 years ago

That's nice to hear, looking forward then.

kylekatarnls commented 7 years ago

Hi, there is a new option now available to use the native pugjs engine (until the 3.0):

$pug = new Pug(array(
    'pugjs' => true
));
echo $pug->render('
-
  var list = ["Uno", "Dos", "Tres",
          "Cuatro", "Cinco", "Seis"]
each item in list
  li= item
');

This is a pure wrapper solution with no PHP support in templates (all run with node.js).

kylekatarnls commented 7 years ago

You can update to 3.0.0-alpha2 (witouht pugsjs option), it should be fixed. Please don't hesitate to test the new pug-php 3 and give us your feedback.