user1491229
user1491229

Reputation: 699

Django template with javascript rendering problem

I ran into a problem when my template contains some javascript. For instance

<script>var i = /{{([a-z]*)}}/gi;</script>

Sure enough the template interpreter wants to interpret everything that is in double curled braces {{}} as a variable. Now I wonder if there is a way to turn off such a behavior similar to {% autoescape off %}{% endautoescape %}.

Upvotes: 0

Views: 52

Answers (1)

Hayden
Hayden

Reputation: 459

You can use built-in tags: {% verbatim %} and {% endverbatim %} like this:

{% verbatim %}
     <script>var i = /{{([a-z]*)}}/gi;</script>
{% endverbatim %} 

Upvotes: 2

Related Questions