Tornado templates setting value field
<p>I have a python array:</p>

<pre><code>a=["a","b","c","d","e","f"]
</code></pre>

<p>I pass this as a value to tornado render:</p>

<pre><code> self.render("index.html", a=a)
</code></pre>

<p>In my html I have the following:</p>

<pre><code>  &lt;input type="hidden" id="xxx" value="
  {% for c in a %}
     {{c}}
  {% end %}
  "/&gt;
</code></pre>

<p>Which gives me the following messy output:</p>

<pre><code>&lt;input type="hidden" id="xxx" value="

a

b

c

d

e

f

"/&gt;
</code></pre>

<p>I tried to use a {{c.strip()}} but that did the same thing. I also trying to mix in javascript however the javascript didn't execute after rendering to populate the value field. I want the html to be normal that is <code>value="a b c d e f"</code></p>

<p>Does anyone know how I can achieve this?</p>

<p>Try Tornado's <a href="http://www.tornadoweb.org/en/stable/template.html#tornado.template.filter_whitespace" rel="nofollow">filter_whitespace</a> feature, new in version 4.3.</p>

<pre><code>  {% whitespace oneline %}
  &lt;input type="hidden" id="xxx" value="{% for c in a %}
     {{c}}
  {% end %}"/&gt;
  {% whitespace all %}
</code></pre>

<p>There will still be a few extra spaces but it's much closer to what you want.</p>

python html tornado