Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 the template does not support the "bundle" parameter

I'm working on a project with friends, using git. Yesterday, a friend pushed some stuff relative to his bundle, but after I pull it, I got this strange error message

An exception has been thrown during the compilation of a template ("The template does not support the "bundle" parameter.") in "layout.html.twig".

I figured out that it's linked to assetic (I tried to remove all my assets and it worked again, but without js nor css files) and it's doing that with all my pages.

The point is, it doesnt work for me, but it works for him. Now, I tried to cache:clear an uncountable amount of times, doctrine:schema:update too. I just want to know what could be the cause of this error, why it's not working so suddenly, and if there's anything I can do about it...

I already tried this even though it's not exactly my problem, doesnt work. Here is my assetic configuration in config.yml, even though wasnt modified

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

Thanks a lot for your help guys !

Edit : where my problem appears to be

The problem doesnt appear in the {% extends %} or at least not for now. It appears in the

{% 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 %}

I tried to remove the @ but it doesnt change anything.

Second edit

Complete config.yml file (hosted on dropbox cause it's a big file, will either upload it on something better or post it full length if required)

like image 320
ovesco Avatar asked Jan 09 '15 12:01

ovesco


3 Answers

The following syntax doesn't work any-more with Symfony 2.6.3 and its default requirements.

If you want to stay with Symfony 2.6.3 without changing the assetic requirement (using dev-master in production is never a good idea...)

Change (@xxx):

{% extends '@MyBundle/layout.html.twig' %}

To:

{% extends 'MyBundle::layout.html.twig' %}

Or stay with Symfony 2.6.3 and use the dev-master requirement of the assetic-bundle as suggested in the accepted answer.

Or switch back to Symfony 2.6.1, I suppose this issue (and the assetic requirement) will be fixed in Symfony 2.6.4.

Check out the issue on Github.

like image 119
COil Avatar answered Sep 30 '22 19:09

COil


You need to update your composer.json as follows:

    "symfony/symfony": "~2.6",
    "symfony/assetic-bundle": "dev-master",

The error comes from assetic in version 2.5.0. The dev version corrects this as explained here: https://github.com/Spea/SpBowerBundle/issues/119

like image 22
Sébastien Avatar answered Sep 30 '22 18:09

Sébastien


If you are trying to include base.html.twig from one of your templates like this:

{% extends 'base.html.twig' %}

You need to change it to this:

{% extends '::base.html.twig' %}

More information here.

like image 35
BadHorsie Avatar answered Sep 30 '22 20:09

BadHorsie