i'm developing Flask App. I want to transfer simple json from the app.py to the html page.
This is the relevant code at app.py:
jsonArr = [{"type": "circle", "label": "New York"},
{"type": "circle", "label": "New York"}]
return render_template('demo.html', foo=42, imgs=jsonArr)
This is how I receive it it javascript script inside the html:
<script>
console.log("HI")
var foo = {{ foo }}
console.log(foo)
var images = {{ imgs }}
console.log(images)
foo is received correctly (I see the printing on the console when I remove the lines for receiving imgs)
But imgs makes error: Uncaught SyntaxError: Unexpected token &
This is what I see in the chrome browser sources:
var images = [['circle', 'New York'], ['triangle', 'Amsterdam']]
This is the html declerations:
<!DOCTYPE html>
<html class="no-js" lang="en">
I've tried adding/removing <meta charset="UTF-8">
but it didn't work.
What am I missing? Thanks