From a Django template, I would like to include an html snippet from a file, say mysnippet.html
:
<div>
blah
</div>
into a javascript variable:
<script type="text/javascript">
var myvar = {% include 'mysnippet.html' %}
</script>
The problem is that the new lines would need to be escaped. Otherwise, Javascript complains for "unterminated string literal".
I know slashes can be added with {{x|addslashes}}
but I don't know how to do it for the {% include %}
tag.