0
什么是最好的隐藏方式木材树枝模板中的某些页面上的导航栏。已尝试包装导航栏中的元素在某些页面上有条件地隐藏内容块的正确方法
{% if post.title !== 'foo bar' %}
// show the nav
{% endif %}
但这并不奏效。
什么是最好的隐藏方式木材树枝模板中的某些页面上的导航栏。已尝试包装导航栏中的元素在某些页面上有条件地隐藏内容块的正确方法
{% if post.title !== 'foo bar' %}
// show the nav
{% endif %}
但这并不奏效。
你不能在树枝中使用!==
。 你必须使用!=
工作片断: https://twigfiddle.com/9l9lrc
{% set var = 'foo bar' %}
{% if var != 'foo bar' %}
<h2>Nav</h2>
{% else %}
<em>no-nav</em>
{% endif %}
感谢。出于兴趣,有没有办法像{%如果var不包含'string'%}? – larpo
是的:http://stackoverflow.com/questions/13007288/find-substring-in-the-string-in-twig – goto