树枝否定开始于

Tad*_*ski 7 twig

starts within twig templates的否定是什么?

我得到像“account”这样的 url 变量,如果我的 url 以“account”开头,则不想显示登录按钮。

在我的例子中,starts with 的否定是什么?

{% if req starts with 'account' %}
<a href="/account">login</a>
{% endif %}
Run Code Online (Sandbox Code Playgroud)

Dar*_*Bee 10

您可以使用 来否定表达式not。为了让它工作,start withs你需要强制twig首先使用括号执行表达式。

{% if not (req starts with 'account') %}
   <a href="/account">login</a>
{% endif %}
Run Code Online (Sandbox Code Playgroud)

演示