Inluded templates in twig print special characters as ascii in assets

329 Views Asked by At

I have a problem with Symfony 2.7.1

I recently upgraded my project from 2.3 to 2.7.1.

I check all my project searching deprecated things to fix it, but when I open an action twig included templates which in turn contain assets, they are shown with bars directory in ASCII.

I leave an example of the problem, see if someone can give me a solution.

In my template

{% block javascripts %}
    {% include 'AdminBundle:Global:notifications.html.twig' %}    
    {% include '::genemu.js.html.twig' with {'form': form} %}
{% endblock %}

And this is the content in genemu.js.html.twig that shows wrongly

{% javascripts output='admin/js/compiled/main_forms.js'
    'bundles/bmatznerjqueryui/js/minified/jquery-ui.min.js'
    'bundles/pinanoselect2/js/select2.full.min.js'
    'uploadify/jquery.uploadify.min.js'
    'tinymce/js/tinymce/jquery.tinymce.min.js'
    'datetimepicker/jquery.datetimepicker.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

It shows like that

<script type="text/javascript" src="\x2Fapp_dev.php\x2Fadmin\x2Fjs\x2Fcompiled\x2Fmain_forms_jquery\x2Dui.min_1.js"></script>
<script type="text/javascript" src="\x2Fapp_dev.php\x2Fadmin\x2Fjs\x2Fcompiled\x2Fmain_forms_select2.full.min_2.js"></script>
<script type="text/javascript" src="\x2Fapp_dev.php\x2Fadmin\x2Fjs\x2Fcompiled\x2Fmain_forms_jquery.uploadify.min_3.js"></script>
<script type="text/javascript" src="\x2Fapp_dev.php\x2Fadmin\x2Fjs\x2Fcompiled\x2Fmain_forms_jquery.tinymce.min_4.js"></script>
<script type="text/javascript" src="\x2Fapp_dev.php\x2Fadmin\x2Fjs\x2Fcompiled\x2Fmain_forms_jquery.datetimepicker_5.js"></script>

I think must be an issue from 2.7.1 because it works fine in 2.3

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

This is because newer versions of Twig are detecting your genemu.js.html.twig as javascript (Because of the js in it) and now the js escaping strategy is used.

Rename your file to genemu.html.twig because it's a html.