django - 无法解析 django 中的提醒

标签 django django-templates jquery-templates

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

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

我尝试过,但 django 显示此错误: 无法解析剩余部分:'""' from 'html ""'

.我该如何做这个django. django中有没有具体的解决方案?

最佳答案

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

替换:

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

与:

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

关于django - 无法解析 django 中的提醒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10382483/

相关文章:

django - 如何从 View 中禁用 Django 的自动转义?

django - 将列表呈现为 django 模板中的 2 列 html 表

jquery-templates - 我如何循环一个奇数/偶数类,因为它在项目上循环?

python - Django 从三个相关表获取信息。连接表

python - 使用 autofield 和 unique_constraint Django

django - 如何获取当前模板中当前url的slug

knockout.js - 模板内的 knockout 绑定(bind)不起作用

jquery - 如何在 Play 中的 groovy 模板中使用 jQuery 模板?

python - 使用 Django Rest Framework 访问 'ManyRelatedManager' 上的不同字段?

Django 在删除时创建 "sentinel"用户