pug-php / pug

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

Can't pass arguments to mixin inside a block #96

Closed mcoenca closed 7 years ago

mcoenca commented 7 years ago

I don't know what's the root cause, but

mixin paragraph(text)
    p=text

+paragraph('yolo')

works

but

mixin paragraph(text)
    p=text

block paragraphs
    +paragraph('yolo')

produces an error in MixinVisitor.php Nodes\Mixin\MixinVisitor\parseMixinArguments line 21 : $arguments = ['0' => 'yolo'] and not $arguments = 'yolo' as expected and it makes the call to explode(',' $arguments) well ... explode ;)

Thanks !

kylekatarnls commented 7 years ago

Hi, thanks for the report, with the refactorization of the project coming and the drop of obsolete stuff, I hope such tricky bugs will go away.

kylekatarnls commented 7 years ago

Hi, there is a new option now available to use the native pugjs engine (as an alternative if you still have blocking bugs with the PHP engine):

$pug = new Pug(array(
    'pugjs' => true
));
echo $pug->render('
mixin paragraph(text)
    p=text

block paragraphs
    +paragraph('yolo')
');

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.