包含一个位于 web 文件夹中的模板

问题描述:

我正在创建一个网站,让人们上传自己的树枝模板.这些模板文件存储在 web 文件夹中.

I am creating a website in which I let people upload their own twig templates. These template files are stored into the web folder.

如何将其中一个文件包含在另一个模板中.

How can I include one of those files in another template.

我试过了:

{% include dirname(__FILE__) ~ '/../../../../web/designs/' ~ target.design.filekey ~ '/DesignKit/design.html.twig' %}

但我收到一个错误,指出 dirname 函数不存在.

But I get an error telling that the dirname function does not exist.

感谢您的帮助:)

use:

{% include '@web_dir/build/templates/templates.html.min.twig' %}

# config.yml
twig:
    paths:
        "%kernel.root_dir%/../web": web_dir