0

根据我找到的文档,我写了 if 表达式。这是我尝试过的:

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

还:

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

和:

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

以上任何一项都不起作用,这让我感到紧张;-)前两个给出:

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

我不评论第三个表达式,因为我承认它的语法不正确。根据所有来源,前两个应该没问题。didYouMean 是idol_response 对象的一个​​字段,我需要检查它是否为空。

我将不胜感激任何帮助。

4

1 回答 1

0

第一个和第二个表达式是一个已知错误,已在 3.0.1 中修复,请查看https://github.com/lyncode/jtwig/pull/179

第三个表达式是操作优先级问题。尝试以下操作:

{% if (not (idol_response.didYouMean == "")) %}
<p>aaaaaaa</p>
{% endif %}
于 2014-10-08T18:24:03.567 回答