【问题标题】:How to write "{{" or "{%" itself in Django template? [duplicate]如何在 Django 模板中编写“{{”或“{%”本身? [复制]
【发布时间】:2011-12-01 11:44:30
【问题描述】:

可能重复:
How to put braces in django templates?

当我使用 jQuery 模板时,我需要在我的 HTML 中使用 {{。它是 Django 模板中的变量分隔符。如何转义它以使 Django 模板系统不会对其做出反应并在生成的 HTML 中具有 {{?

UPD:记录在案https://docs.djangoproject.com/en/dev/ref/templates/builtins/#templatetag

【问题讨论】:

  • templatetag 选项太冗长以至于在尝试编写时变得很愚蠢,例如jquery 模板。在我看来,对于这种情况,verbatim 之类的要点要优越得多

标签: django templates escaping


【解决方案1】:

我已经使用来自this gistverbatim 标记并取得了一些成功

【讨论】:

  • verbatim 比 templatetag 更好,谢谢!
猜你喜欢
  • 2016-03-30
  • 1970-01-01
  • 2011-04-15
  • 2016-09-07
  • 2018-08-28
  • 2011-07-17
  • 1970-01-01
  • 2018-06-23
  • 2021-12-13
相关资源
最近更新 更多