Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 Timber 文件 (.twig) 在特定页面上输出一些 HTML 内容。我已经能够在主页上输出内容,但不能在特定页面上输出。
我尝试了以下代码:
% if fn (is_page('proprietes')) %} <h5 class="widget__headline">Test</h5> {% endif %}
但我最终得到一个空白页。我可能犯了转储语法错误...
谢谢你的帮助。
正确方法:
{% if fn('is_page', page) %}
“页面”可以是 slug/id/id 数组等。
尝试使用 id 而不是 slug,例如:
{% if fn (is_page(7)) %} <h5 class="widget__headline">Test</h5> {% endif %}