gpt4 book ai didi

Twig- 包含来自其他目录的模板

转载 作者:行者123 更新时间:2023-12-04 17:52:58 24 4
gpt4 key购买 nike

是否可以包含带有 {% include %} 的模板?它在定义的模板路径之外:

$template = $twig->loadTemplate('example.tpl'); 

我问它是因为这条线不起作用:
{% include '.../example/navbar_left.tpl' %}

最佳答案

您可以将第二条路径添加到您的 twig.yaml (symfony 4.4)

twig:
paths:
- '%kernel.project_dir%/templates'
- '%kernel.project_dir%/example'
然后只需使用名称 {% include 'navbar_left.tpl' %}

关于Twig- 包含来自其他目录的模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13018034/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com