添加命名空间的树枝路径

adding namespaced twig paths

我想在我的 symfony 项目中使用 bootstrap 4 CoreUi 模板。 我用

将它添加到我的项目中

composer require coreui/coreui

现在 coreui 在我的供应商目录中,我想在 twig.yaml 中添加一个路径以简化其访问,根据 the doc 我修改了我的 twig.yaml 文件,如下所示:

twig:
#    paths: ['%kernel.project_dir%/templates']
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    paths:
        - '%kernel.project_dir%/templates'
        - '%kernel.project_dir%/vendor/coreui': coreui

我收到错误异常:

Notice: Undefined index: value

文档没有说太多...所以我现在不知道该怎么做。

paths: 正在获取两个参数作为 array,此处

%kernel.project_dir%/templates%kernel.project_dir%/vendor/coreui 是必须存在的目录,如果不存在则需要创建或删除,如果不需要其中之一。

我的是这样的:

twig:
    paths: ['%kernel.project_dir%/templates']
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%' 

很抱歉在我的评论中发布了错误的 link。您得到的错误是一根树枝 "feature"。基本上只需要为空白命名空间提供一个值。

twig:
   #paths: ['%kernel.project_dir%/templates']
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    paths:
       #'%kernel.project_dir%/templates': '' # add : ''
        '%kernel.project_dir%/vendor/coreui': coreui

运行 bin/console debug:twig 一切都会好起来的。

更新:基于下面与@yceruto 的讨论以及这个 github issue,我更改了答案以简单地注释掉默认模板行。事实证明它不需要,并且有一个删除它的拉取请求。一直想知道为什么它首先在那里。