【发布时间】:2011-09-26 10:10:00
【问题描述】:
我想在模板变量中放入 html 片段。像这样的:
>>>t = django.template.Template("<ul>{{ title }}<\ul>: {{ story }}")
>>>c = django.template.Context({"title":"This is the title",r"Line 1.<br />Line 2."})
>>>print t.render(c)
<ul>This is the title<\ul>: Line 1.<br />Line 2.
我希望输出是这样的:
<ul>This is the title<\ul>: Line 1.<br />Line 2.
如何在模板变量中放入 HTML?
【问题讨论】:
标签: python html django django-templates escaping