简体   繁体   中英

Jtwig if expression fails: Unable to find implementation for operator !=

I wrote if expression, according documentation I found. Here is what I tried:

{% if idol_response.didYouMean != "" %}
    <p>aaaaaaa</p>
{% endif %}

also:

{% if (idol_response.didYouMean != "") %}
    <p>aaaaaaa</p>
{% endif %}

and:

{% if (not idol_response.didYouMean == "") %}
    <p>aaaaaaa</p>
{% endif %}

Any of the above do not work, which kind of makes me nervous ;-) The first two gives:

HTTP Status 500 - Request processing failed; nested exception is com.lyncode.jtwig.exception.CompileException: Unable to find implementation for operator !=

I do not comment the third expression, because I admit it is not correct syntax. First two should be fine acording to all sources. didYouMean is a field of idol_response object and I need to check if it is empty or not.

I would appreciate any help.

The first and second expressions was a known bug, which was fixed in 3.0.1, check https://github.com/lyncode/jtwig/pull/179 .

The third expression is an operation precedence issue. Try the following:

{% if (not (idol_response.didYouMean == "")) %}
<p>aaaaaaa</p>
{% endif %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM