How can I safely add a piece of HTML with Django template tags in it using Javascript? For example, if I have something like this in my template:
<div id="some-element">
<span id="my-tag">{{ my_data }}</span>
</div>
<!-- rest of the html page -->
If I were to use a script to just edit the innerHTML of the div, like the script below, it'd would just read {{ other-data }}
as a string. How can I make it become an actual Django template tag?
<script>
document.getElementById("some-element").innerHTML =
`
<h1>This is may new data {{ other-data }} </h1>
{% if value %}
<p>This is an if statement</p>
{% endif %}
`
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…