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

Created on 16 Oct 2019  路  11Comments  路  Source: phalcon/cphalcon

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
bug low

Most helpful comment

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

All 11 comments

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

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

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

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 What version of Phalcon do you use?

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

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

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

Version | 4.0.0-rc.3
Php 7.3

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 I'll try to sort out ASAP

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

Fixed in #14909

Was this page helpful?
0 / 5 - 0 ratings