It is possible you have Javascript read vars from Django template tags like var spec = "{{ foo }}";
.
However, if foo needs to be a JSON object. it becomes like this:
var spec = "{"2": {"guid": 2, "contentBlocks": {"2_1": {"guid": "2_1", "type": "list"}}}}";
The preceding and closing quotes make this an invalid JavaScript syntax, however, if I leave them out, it is also an invalid syntax var spec = {{ foo }};
What would be the best way to solve this problem? Either to have foo
output the complete <script></script>
block, or to have JavaScript request this object from the server, instead of outputting it via a template tag? ......