Django variable to javascript '&' character -
so when trying pass list of country codes javascript, replaces single quotes -> ' ' tried replace of regular expression, not work. i'm wondering why not work have single quotes
function drawregionsmap() { (item in {{countries}}) { item.replace(/'/g, "'"); } var data = google.visualization.arraytodatatable([ {{countries}} ); in javascript it's this:
function drawregionsmap() { (item in [['country'], ['au'], ['at'], ['be'], ['bo'], ... ['li'], ['mc'], ['id']]) { item.replace(/'/g, "'"); } var data = google.visualization.arraytodatatable([ [['country'], ['au'], ['at'], ['be'], ['bo'], ['co'], ... ['id']] ); so need pass django variable javascript different way? possible? appreciated
the error: syntaxerror: expected expression, got '&'
apparantly fixed doing {{countries|safe}}. believe that's being used escape characters. mike c providing link, solution found here