cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[BUG]: Exception thrown when using 'is defined' inside {{ }} in Volt

Open sheroesde opened this issue 7 years ago • 11 comments

In Volt (using Phalcon\Mvc\Volt\Simple) I sometimes using shorthand notation for IF/ELSE like:

{{ someVar is defined ? 'yes' : 'no' }}

In Phalcon 3.4 all is fine, but it is broken in 4.0.0-rc.1, where I get

Phalcon\Mvc\View\Exception: Syntax error, unexpected token IDENTIFIER(is) in /home/my-project/app/views/premium.volt

sheroesde avatar Oct 16 '19 11:10 sheroesde

Confirmed, although it does work within the {% %} tags, for example:

{% set myVar = someVar is defined ? 'yes' : 'no' %}

zsilbi avatar Oct 17 '19 11:10 zsilbi

Well as i see @sergeyklay was doing some changes to volt parsers etc lately so maybe it was some of his change?

Jurigag avatar Oct 17 '19 12:10 Jurigag

same for me

{{ uploadedPhoto is user.avatar ? 'checked="checked"' : '' }}

Syntax error, unexpected token IDENTIFIER(is) in /....../views/registered/widgets/avatar.twig on line 31

elcreator avatar Nov 24 '19 04:11 elcreator

@elcreator What version of Phalcon do you use?

Jeckerson avatar Nov 24 '19 09:11 Jeckerson

Version | 4.0.0-rc.3 Build Date | Nov 16 2019 20:03:22 Powered by Zephir | Version 0.12.10-fedc314 PHP Version | 7.2.24-1

elcreator avatar Nov 24 '19 12:11 elcreator

as temporary fix I have replaced "is" with "=="

elcreator avatar Nov 24 '19 12:11 elcreator

The same for me {{ title is empty ? siteName : title }} => Syntax error, unexpected token IDENTIFIER(is) ...

Version | 4.0.0-rc.3 Php 7.3

mvanvu avatar Dec 02 '19 08:12 mvanvu

What's the status on this? We have a lot of code written for v4.0.0-rc.1 and we can't update to the latest version since this will imply rewriting A LOT of code.

Do you expect this to be fixed any time soon, or should we go ahead and rewrite everything?

madrian-es avatar Mar 11 '20 08:03 madrian-es

@madrian-es I'll try to sort out ASAP

sergeyklay avatar Mar 11 '20 19:03 sergeyklay

Status update: I fixed the issue. Thinking about better internal implementation

sergeyklay avatar Mar 12 '20 15:03 sergeyklay

Fixed in #14909

sergeyklay avatar Mar 12 '20 22:03 sergeyklay