Issue
I am trying to assign javascript array as jinja variable but it throws error
- i want the data to be taken as a array
Solution
You can simply pass your list to the template. You can do without the conversion to JSON here.
return render_template('game.html', game=game, board=board)
To then use this variable in javascript, you can use the Jinja2 filter tojson
. The result is your list as an array.
window.onload = start({{ board | tojson }});
Answered By - Detlef Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.