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>The same as @Avinash answered, only in-template:</p>

<pre><code>&lt;input type="hidden" id="xxx" value="{{ ' '.join(a) }}" /&gt;
</code></pre>

<p>Tornado templates, unlike some other templating engines like Django or Jinja, allows arbitrary Python expressions in the templates.</p>

python html tornado