Symfony:"Template "bootstrap_3_layout.html.twig“不能用作特征”
Symfony: "Template "bootstrap_3_layout.html.twig" cannot be used as a trait"
我正在尝试使用 Symfony's Bootstrap 3 form theme 文件,包括如下内容:
# config.yml
twig:
form_themes:
- 'WOSECoreBundle:Form:WOSE_form_theme.html.twig'
WOSE_form_theme.html.twig
看起来像这样:
{% use "bootstrap_3_layout.html.twig" %}
{% block button_widget -%}
{% set attr = attr|merge({class: (attr.class|default('btn-primary') ~ ' btn')|trim}) %}
{{- parent() -}}
{%- endblock %}
但是,每当我浏览到我的应用程序中使用表单的页面时,我都会看到以下错误:
"Template "bootstrap_3_layout.html.twig" cannot be used as a trait"
知道这里出了什么问题吗?
我在 Symfony 的 github 帐户上看到了 a similar issue,其中包括揭示性的评论 "A template is not traitable if it extends another one."
Twig 中的 "Traits" 是水平重用,使用 use
tag - 我们在 WOSE_form_theme.html.twig
中正在做的这一行:{% use "bootstrap_3_layout.html.twig" %}
.
Prior to Symfony 2.6.5,Symfony 的 Bootstrap3 模板包含以下行:
{% extends "form_div_layout.html.twig" %}
这个模板 extends
是另一个模板,因此无法通过 use
(它 "is not traitable")引用它,而我们正试图这样做。在 Symfony 2.6.5 及更高版本中,Bootstrap 模板改为包含此行:
{% use "form_div_layout.html.twig" %}
这个 >=2.6.5 版本的模板不再扩展另一个,因此可以根据需要通过 use
安全地引用。
将我的项目从 Symfony 2.6.3 升级到 2.6.5 因此解决了这个问题!
我正在尝试使用 Symfony's Bootstrap 3 form theme 文件,包括如下内容:
# config.yml
twig:
form_themes:
- 'WOSECoreBundle:Form:WOSE_form_theme.html.twig'
WOSE_form_theme.html.twig
看起来像这样:
{% use "bootstrap_3_layout.html.twig" %}
{% block button_widget -%}
{% set attr = attr|merge({class: (attr.class|default('btn-primary') ~ ' btn')|trim}) %}
{{- parent() -}}
{%- endblock %}
但是,每当我浏览到我的应用程序中使用表单的页面时,我都会看到以下错误:
"Template "bootstrap_3_layout.html.twig" cannot be used as a trait"
知道这里出了什么问题吗?
我在 Symfony 的 github 帐户上看到了 a similar issue,其中包括揭示性的评论 "A template is not traitable if it extends another one."
Twig 中的"Traits" 是水平重用,使用 use
tag - 我们在 WOSE_form_theme.html.twig
中正在做的这一行:{% use "bootstrap_3_layout.html.twig" %}
.
Prior to Symfony 2.6.5,Symfony 的 Bootstrap3 模板包含以下行:
{% extends "form_div_layout.html.twig" %}
这个模板 extends
是另一个模板,因此无法通过 use
(它 "is not traitable")引用它,而我们正试图这样做。在 Symfony 2.6.5 及更高版本中,Bootstrap 模板改为包含此行:
{% use "form_div_layout.html.twig" %}
这个 >=2.6.5 版本的模板不再扩展另一个,因此可以根据需要通过 use
安全地引用。
将我的项目从 Symfony 2.6.3 升级到 2.6.5 因此解决了这个问题!