Reputation: 867
Well, that's really strange, Twig (I'm using it with Symfony 3) replaces non - ascii characters (for example "ł") with entities (e.g. ł
), but... only in Javascript sections.
I have no idea why and how to disable it.
Edit: yes, I have UTF-8 everywhere, in Nebeans and in HTML head section.
Edit2: here is my current code:
{% autoescape false %}
<script>
$(function(){
alert('ółż');
})
</script>
{% endautoescape %}
Even with {% autoescape false %}
(as suggested by Martin) it still does it.
Upvotes: 0
Views: 1804
Reputation: 96891
Twig uses different autoescaping strategies based on the context. See manual http://twig.sensiolabs.org/doc/tags/autoescape.html
You can force Twig to disable escaping with:
{% autoescape false %}
Everything will be outputted as is in this block
{% endautoescape %}
Or for a single print expression with raw
filter:
{{ var|raw }}
Also have a look at your Twig 's configuration where autoescaping
should be enabled by default.
Edit:
Maybe try also this:
<script>
{% autoescape false %}
$(function(){
alert('ółż');
})
{% endautoescape %}
</script>
Upvotes: 1
Reputation: 872
Hi if the caracters are in a variable it's normal, to disabled you can use :
{{myvar | raw}}
Source if you need : http://twig.sensiolabs.org/doc/filters/raw.html
Upvotes: 3