Search code examples
djangodjango-templatesjquery-templates

Could not parse the reminder in django


I want to add a script tag inside a jquery template. So am referring to this link. It tells to close the inner script tag in the following way :

<script id="filaVideoTemplate" type="text/x-jQuery-tmpl">
    <!-- Some HTML here -->
    <script type="text/javascript">
    <!-- Some javascript here -->
    {{html "</sc"+"ript>"}}
</script>

I tried it, but django shows this error: Could not parse the remainder: '" < /sc"+"ript>"' from 'html "< /sc"+"ript>"'

.How can I do this django. Is there any specific solution in django for this?


Solution

  • { and } are reserved characters in Django templates, so you need to use templatetag.

    Replace:

    {{html "</sc"+"ript>"}}
    

    With:

    {% templatetag openbrace %}{% templatetag openbrace %}html "</sc"+"ript>"{% templatetag closebrace %}{% templatetag closebrace %}