There is a lot of documentation available in including static files in Django templates. However, I cannot find anything on how to use Django template syntax in static files.
I had an html file that included javascript between tags like this:
var nodes = JSON.parse('{{nodes|safe}}');
I now moved all the javascript to a static .js file which I'm serving. It is included in the HTML file like this:
<script src="{% static 'citator/analysis.js' %}" type="text/javascript"></script>
Everything runs fine except for the parts of the .js file which use the Django template syntax.
My question is, is there a way to use Django template syntax in the javascript if the javascript is not directly in the template, but served as a static file and imported? Or do I have to get the context data in the template, and then pass it to functions in the static file?