At the begining of launching my app I am getting variables through django templates variables like so:
var my_variable = '{{ variable }}';
But sometimes it takes more than one line and provide a syntax error
var my_variable = "This should be a good variable;
But it isn't";
How to avoid Uncaught SyntaxError: Unexpected token ILLEGAL?
You can try this solution
<script>
{% autoescape off %}
var my_variable = "{{ variable|escapejs }}"
{% endautoescape %}
</script>
escapejs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With