I'm using MopaBootstrapBundle in Symfony 2.1.3 with Twig templates. This bundle has base.html.twig template which contains scripts block:
{% block foot_script %}
{# To only use a subset or add more js overwrite and copy paste this block
To speed up page loads save a copy of jQuery in your project and override this block to include the correct path
Otherwise the regeneration is done on every load in dev more with use_controller: true
#}
{% javascripts
'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-transition.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-modal.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-dropdown.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-scrollspy.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-tab.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-tooltip.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-popover.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-alert.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-button.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-collapse.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-carousel.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-typeahead.js'
'@MopaBootstrapBundle/Resources/public/js/mopabootstrap-collection.js'
'@MopaBootstrapBundle/Resources/public/js/mopabootstrap-subnav.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock foot_script %}
I'm extending it in my template using:
{% extends 'MopaBootstrapBundle::base.html.twig' %}
{% block foot_script %}{% endblock foot_script %}
But it still tries to load Bundle's base.html.twig template and I get:
An exception has been thrown during the compilation of a template ("Unable to find file "@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-transition.js".") in "MopaBootstrapBundle::base.html.twig".
What I've found out is, that if you extend it like this:
{% extends 'MopaBootstrapBundle::base.html.twig' %}
{% block foot_script %}
{% javascripts
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-typeahead.js'
'@MopaBootstrapBundle/Resources/public/js/mopabootstrap-collection.js'
'@MopaBootstrapBundle/Resources/public/js/mopabootstrap-subnav.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock foot_script %}
Note the typeahead.js
I get:
An exception has been thrown during the compilation of a template ("Unable to find file "@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-typeahead.js".") in "MopaBootstrapBundle::base.html.twig".
If I remove just one line:
{% extends 'MopaBootstrapBundle::base.html.twig' %}
{% block foot_script %}
{% javascripts
'@MopaBootstrapBundle/Resources/public/js/mopabootstrap-collection.js'
'@MopaBootstrapBundle/Resources/public/js/mopabootstrap-subnav.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock foot_script %}
I get:
An exception has been thrown during the compilation of a template ("Unable to find file "@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-transition.js".") in "MopaBootstrapBundle::base.html.twig".
It still tries to load all the scripst from base template.
Any suggestions how to override *foot_script* block to make it empty and not to load these JS files?
{% javascripts %}tag is parsed and after that the{% block %}tags. I don't know how you can fix this. This issue by fabpot can maybe help you?