title: Handing over unicode strings to javascript with jinja2
body: <p>I am using GAE and at some stage I decode a UTF8 string to then hand it over to an HTML file with Jinja2:</p>
  
  <pre><code>  for i in report:
          unique_channels.append(i[0][j].decode("utf8"))
  
      template_values = {
          "unique_channels" : unique_channels,
          "result" : result
      }
  </code></pre>
  
  <p>Now, when I use Jinja2 to iterate over this list of unicode strings, all is good. But when I pass this list to Javascript, Javascript throws an unexpected string error. I assume the reason is the u'xxx'/Unicode strings.</p>
  
  <pre><code>var unique_channels = {{ unique_channels }};
  
  for (var i = 1; i &lt; 11; i++) {
     new_data.push({"Position" : i.toString()})
      for (var k = unique_channels.length - 1; k &gt;= 0; k--) {
        new_data[i-1][unique_channels[k]] = 0;
      } 
  };
  </code></pre>
  
  <p>How do I avoid this? Should I pass the list to javascript in a different way? Any suggestions?</p>
  
  <p>EDIT: Second part where I use the unique_channels list:</p>
  
  <pre><code>{% for j in unique_channels %}
  &lt;br&gt;&lt;input type="checkbox" class="checkbox" name="{{ j }}" value="{{ j }}" onclick="updateData();" checked&gt; {{ j }}
  {% endfor %}
  </code></pre>
  
  <p>This will be treated as string when I use json.dumps</p>