I am using Bottle as a web server and need to pass a python list to javascript.
When I am doing just {{myList}}, Bottle escapes single quotes for strings in the list and shows them as '
JS, in turn, isn’t very happy with what it gets.
I managed to find a solution, but I don’t think it’s an optimal one.
var tempList = '{{eval(myList)}}'.replace(/'/g, "'");
var myNewList = eval(tempList);
I wonder, is there a better way to do this?
upd: I moved the solution I found into the ‘Answers’ section.
I started using json (json_dumps in Python3, simplejson won’t install), but bottle was still escaping single quotes. I found in Bottle manual that you can skip escaping using the exclamation sign and changed my code: