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