I am building a Django template which will use jsrender in order to build out dynamic Javascript templates for html code.
However, I find that when I put a Jsrender template in my code, Django flips out because Django parses anything between {{
and }}
as a variable, and Jsrender uses this for its own variables. For instance, a template in Jsrender might look like:
<script id="headerTemplate" type="text/x-jsrender">
<h1>{{:label}}</h1>
</script>
Django sees {{:label}}
and tries to parse it, which leads to an error.
Is there a Django block I can invoke which would make Django not parse any text within it? Or otherwise to escape a {
character?
You can choose alternative delimiters in JsRender, so as to avoid the conflict with Django delimiters.
https://www.jsviews.com/#settings/delimiters
For example:
$.views.settings.delimiters("<%", "%>");
will change the tag syntax to <%...%>
.