I'm trying to parse a list into js.
I have tried a few workarounds but I can't seem to access the array to begin looping through.
def parse_list(request):
first_list = [
['Harlem Babies Limited', 'Harlem Babies Limited', 52.0561, 1.154311],
['Guardians of the Galaxy Ltd', 'Guardians of the Galaxy Ltd', 51.8866354323239, 0.185223639282133],
['Marvel Limited', 'Marvel Limited',52.5653341835845, -0.242548375987545],
['Mantaray Marketing Limited', 'Mantaray Marketing Limited', 52.331251, 0.332465]
]
second_list = json.dumps(first_list)
return render(request,'temp.html', 'second_list':second_list)
Template
<html>
<script type="text/javascript">
var second_list = '{{second_list}}';
</script>
</html>
I expected the outcome to be...
second_list = [
['Harlem Babies Limited', 'Harlem Babies Limited', 52.0561, 1.154311],
['Guardians of the Galaxy Ltd',
'Guardians of the Galaxy Ltd',
51.8866354323239,
0.185223639282133],
['Marvel Limited', 'Marvel Limited', 52.5653341835845, -0.242548375987545],
['Mantaray Marketing Limited',
'Mantaray Marketing Limited',
52.331251,
0.332465]
]
But the actual output is...
second_list = "[["Harlem Babies Limited", "Harlem Babies Limited", 52.0561, 1.154311], ["Guardians of the Galaxy Ltd", "Guardians of the Galaxy Ltd", 51.8866354323239, 0.185223639282133], ["Marvel Limited", "Marvel Limited", 52.5653341835845, -0.242548375987545], ["Mantaray Marketing Limited", "Mantaray Marketing Limited", 52.331251, 0.332465]]"
'from the javascript wrapping the mustache braces?