Django javascript escape characters

Posted by Hulk on Stack Overflow See other posts from Stack Overflow or by Hulk
Published on 2010-05-17T09:03:41Z Indexed on 2010/05/17 9:10 UTC
Read the original article Hit count: 490

There is a text area in which the data is entered as,

         122
        //Enter button pushed
        Address
        Name
         //Enter button pushed
         1

And the same is tored in the db.And the data is fetched in views and returned it to template as,

          <script> 
         {% for i in dict.row_arr %}
           var ii= ('{{ i }}');
           row_arr.push( ii );   
         {% endfor %}
         </script>

Here there is an error as

             Error: unterminated string literal
            Line: 40, Column: 12
            Source Code:
          var ii= ('1212 

And when the html source shows up as,

            var ii= ('1212
               1
            21

           11212121212');
                 row_arr.push( ii );  

How should the escape function be applied here.

Thanks..

© Stack Overflow or respective owner

Related posts about django

Related posts about django-templates