2

我想在 jquery 模板中添加一个脚本标签。所以我指的是这个链接。它告诉以下列方式关闭内部脚本标签:

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

我试过了,但 django 显示此错误:无法解析剩余部分:'" < /sc"+"ript>"' from 'html "< /sc"+"ript>"'

.我该怎么做这个django。django 中对此有什么具体的解决方案吗?

4

1 回答 1

2

{}是 Django 模板中的保留字符,因此您需要使用templatetag.

代替:

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

和:

{% templatetag openbrace %}{% templatetag openbrace %}html "</sc"+"ript>"{% templatetag closebrace %}{% templatetag closebrace %}
于 2012-04-30T10:55:20.553 回答