Javascript is not recognizing a Flask variable
<p>I'm passing a set of variables into a Flask template, and I would like to first manipulate them with Javascript. The problem is that when I use the <code>{{ var }}</code> syntax, Javascript isn't recognizing it.
<a href="http://i.stack.imgur.com/fLkdB.png" rel="nofollow">The errors look like this.</a> The left brackets give an "Identifier or string literal or numeric literal expected" error, and the variable names give an "Expression statement is not assignment or call" error.</p>

<p>I use <code>{{ var }}</code> syntax later, within the HTML portion of the document, and when I do that they appear just fine. Also, enclosing it in quotes as I do for a different variable doesn't work either. Anyone know what the issue could be? Thanks.</p>

<p>Jinja2 (flask's templating engine) is a preprocessor, meaning that its output is the real JS and it does not care about you're using it with HTML, JS or whatever, it only prints text.</p>

<p>That error you're getting is your text editor trying to help you but it's not smart enough to realize you're writing Jinja2 instead of javascript.</p>

<p><strong>Edit</strong>: also, as @davidism says, you have to use jinja2 blocks.</p>

javascript python flask