Symfony2模板不支持"bundle"参数
Symfony2 the template does not support the "bundle" parameter
我正在和朋友一起做一个项目,使用 git。昨天一个朋友推了一些东西到他的bundle,但是我拉了之后,我得到了这个奇怪的错误信息
在"layout.html.twig".
中编译模板("The template does not support the "bundle"参数。")期间抛出异常
我发现它与 assetic 相关联(我试图删除我的所有资产,但它再次运行,但没有 js 和 css 文件)并且我的所有页面都这样做。
关键是,它对我不起作用,但对他有用。现在,我尝试了无数次 cache:clear
,doctrine:schema:update
。我只是想知道这个错误的可能原因是什么,为什么它突然不工作,如果有什么我可以做的...
我已经尝试了 this 尽管这不完全是我的问题,但没有用。这是我在 config.yml 中的资产配置,即使没有修改
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: []
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
assets:
jquery: %kernel.root_dir%/../vendor/components/jquery/jquery.min.js
非常感谢你们的帮助!
编辑:我的问题似乎是
问题没有出现在 {% extends %} 中,至少现在没有。它出现在
{% stylesheets '@AppBundle/Resources/public/css/*' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% javascripts
'@AppBundle/Resources/public/js/alwaysIncluded/*'
'@AppBundle/Resources/public/js/layout.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
我试图删除 @ 但它没有改变任何东西。
第二次编辑
Complete config.yml 文件(托管在 dropbox 上,因为它是一个大文件,将上传到更好的东西或 post 如果需要,它的全长)
以下语法不再适用于 Symfony 2.6.3
及其默认要求。
如果您想在不更改资产要求的情况下继续使用 Symfony 2.6.3
(在生产中使用 dev-master
绝不是一个好主意...)
更改 (@xxx):
{% extends '@MyBundle/layout.html.twig' %}
收件人:
{% extends 'MyBundle::layout.html.twig' %}
或 留在Symfony 2.6.3
并按照接受的答案中的建议使用assetic-bundle
的dev-master
要求。
或切换回Symfony 2.6.1
,我想这个问题(和资产要求)将在Symfony 2.6.4
.
中得到解决
您需要按如下方式更新您的 composer.json:
"symfony/symfony": "~2.6",
"symfony/assetic-bundle": "dev-master",
错误来自assetic 2.5.0版本。开发版本更正了这里的解释:
https://github.com/Spea/SpBowerBundle/issues/119
如果您尝试从这样的模板之一中包含 base.html.twig
:
{% extends 'base.html.twig' %}
你需要改成这样:
{% extends '::base.html.twig' %}
我正在和朋友一起做一个项目,使用 git。昨天一个朋友推了一些东西到他的bundle,但是我拉了之后,我得到了这个奇怪的错误信息
在"layout.html.twig".
中编译模板("The template does not support the "bundle"参数。")期间抛出异常我发现它与 assetic 相关联(我试图删除我的所有资产,但它再次运行,但没有 js 和 css 文件)并且我的所有页面都这样做。
关键是,它对我不起作用,但对他有用。现在,我尝试了无数次 cache:clear
,doctrine:schema:update
。我只是想知道这个错误的可能原因是什么,为什么它突然不工作,如果有什么我可以做的...
我已经尝试了 this 尽管这不完全是我的问题,但没有用。这是我在 config.yml 中的资产配置,即使没有修改
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: []
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
assets:
jquery: %kernel.root_dir%/../vendor/components/jquery/jquery.min.js
非常感谢你们的帮助!
编辑:我的问题似乎是
问题没有出现在 {% extends %} 中,至少现在没有。它出现在
{% stylesheets '@AppBundle/Resources/public/css/*' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% javascripts
'@AppBundle/Resources/public/js/alwaysIncluded/*'
'@AppBundle/Resources/public/js/layout.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
我试图删除 @ 但它没有改变任何东西。
第二次编辑
Complete config.yml 文件(托管在 dropbox 上,因为它是一个大文件,将上传到更好的东西或 post 如果需要,它的全长)
以下语法不再适用于 Symfony 2.6.3
及其默认要求。
如果您想在不更改资产要求的情况下继续使用 Symfony 2.6.3
(在生产中使用 dev-master
绝不是一个好主意...)
更改 (@xxx):
{% extends '@MyBundle/layout.html.twig' %}
收件人:
{% extends 'MyBundle::layout.html.twig' %}
或 留在Symfony 2.6.3
并按照接受的答案中的建议使用assetic-bundle
的dev-master
要求。
或切换回Symfony 2.6.1
,我想这个问题(和资产要求)将在Symfony 2.6.4
.
您需要按如下方式更新您的 composer.json:
"symfony/symfony": "~2.6",
"symfony/assetic-bundle": "dev-master",
错误来自assetic 2.5.0版本。开发版本更正了这里的解释: https://github.com/Spea/SpBowerBundle/issues/119
如果您尝试从这样的模板之一中包含 base.html.twig
:
{% extends 'base.html.twig' %}
你需要改成这样:
{% extends '::base.html.twig' %}