Symfony2:如何排除1 js资产文件?

时间:2014-08-13 09:51:48

标签: javascript php symfony

默认情况下,我的所有脚本都会加载到head部分,并在文件夹js/内。但是,我希望其中一个脚本文件不会被其他脚本文件加载。如何排除这个文件?

代码base.html.twig

....
{% block javascripts %}
    {% javascripts 
        '@AcmeDemoBundle/Resources/public/js/jquery-1.11.0.js'
        '@AcmeDemoBundle/Resources/public/js/*'
        '@AcmeDemoBundle/Resources/public/js/*/*'%}
    <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}
....

code index.html.twig

{% extends "::base.html.twig" %}
....
{# in footer #}
<script src="{{ asset('/bundles/acmedemo/js/clipboard.js') }}"></script>
<script src="{{ asset('/bundles/acmedemo/js/ZeroClipboard.min.js') }}"></script>
<script src="{{ asset('/bundles/acmedemo/js/config.js') }}"></script>
...

输出

...
<script type="text/javascript" src="/app_dev.php/js/e900114_jquery-1.11.0_1.js"></script>
<script type="text/javascript" src="/app_dev.php/js/e900114_part_2_ZeroClipboard.min_1.js"></script>
<script type="text/javascript" src="/app_dev.php/js/e900114_part_2_ZeroClipboard_2.js"></script>
<script type="text/javascript" src="/app_dev.php/js/e900114_part_2_bootstrap.min_3.js"></script>
<script type="text/javascript" src="/app_dev.php/js/e900114_part_2_clipboard_4.js"></script>
<script type="text/javascript" src="/app_dev.php/js/e900114_part_2_config_5.js"></script>
<script type="text/javascript" src="/app_dev.php/js/e900114_part_2_daterangepicker_6.js"></script>
<script type="text/javascript" src="/app_dev.php/js/e900114_part_2_moment_8.js"></script>
....
{# in footer #}
<script src="/bundles/acmedemo/js/clipboard.js"></script>
<script src="/bundles/acmedemo/js/ZeroClipboard.min.js"></script>
<script src="/bundles/acmedemo/js/config.js"></script>

ZeroClipboard重复

1 个答案:

答案 0 :(得分:1)

创建内部文件夹。将所有文件放在其中,但要包含的文件除外。

在你的脑袋中加载内部文件夹。并包含所有文件加载外部文件夹。