Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Multiple conditions not working with `expressionLanguage => 'js'` option. #216
I encountered an issue with the following code with rendering option
doctype html html body if falsy || !falsy || !falsy p 1 else p 2
array( 'falsy' => false )
I expected to get:
<!DOCTYPE html> <html> <body> <p>1</p> </body> </html>
But I actually get:
<!DOCTYPE html> <html> <body> <p>2</p> </body> </html>
js-phpize-phug 2.x will occer this error, but 1.x not occerred.
Hi, this a side effect of handling
You can wrap:
doctype html html body if falsy || (!falsy) || (!falsy) p 1 else p 2
Or force js-phpize
<?php include __DIR__.'/vendor/autoload.php'; $pug = new Pug([ 'module_options' => [ 'jsphpize' => [ 'booleanLogicalOperators' => true, ], ], ]); echo $pug->renderString('doctype html html body if falsy || !falsy || !falsy p 1 else p 2 ', [ 'falsy' => false, ]);
It might be handled in a next major version of https://github.com/pug-php/js-phpize but not planned yet.
Is this issue documented anywhere? Because just ran into this, and thought we were going crazy, and now we are worried about this issue happening all over the place and we just didnt realise...
You just kinda expect multiple conditions to work as normal, and when it doesnt its super confusing, probably should be a big warning in the readme