树枝中的动态JS路线[重复]

This question already has an answer here:

I want to include different js file, depending on environment. I've tried:

{% javascripts
    'bundles/fosjsrouting/js/router.js'
    'bundles/fosjsrouting/' ~ app.environment ~ '/js/fos_js_routes.js'
    filter='?yui_js'
    output='compiled/routing'
    %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
 {% endjavascripts %}

But it gives error about unexpected character ~. Any suggestions?

</div>

That isn't possible unfortunately at the moment. This is because you can't use variables in Assetic paths.

However, you could use asset twig helper:

<script src="{{ asset('bundles/fosjsrouting/' ~ app.environment ~ '/js/fos_js_routes.js') }}"></script>