{'quotes': u'Live before you die.\n\n"Dream as if you\'ll live forever, live as if you\'ll die today"\n\n"Love one person, take care of them until you die. You know, raise kids. Have a good life. Be a good friend. Try to be completely who you are, figure out what you personally love and go after it with everything you\'ve got no matter how much it takes." -Angelina Jolie.'}
注意我的字典中有换行符:\n
如何显示带有换行符的模板?
{{带换行符的引号\n}
使用
'<br>'
而不是/n
。如有必要,您可以执行
.replace('/n', '<br>')
。使用^{} 过滤器。
例如:
如果值为
Joel\nis a slug
,则输出为<p>Joel<br />is a slug</p>
。您还可以使用^{} 过滤器将所有新行简单地转换为
<br>
没有额外的<p>
。示例:
如果
value
是Joel\nis a slug
,则输出为Joel<br>is a slug
。与Ignacio's answer(} 。
linebreaks
过滤器)的区别在于linebreaks
尝试猜测文本中的段落,并将每个段落包装在<p>
中,其中linebreaksbr
只是substitutes newlines with ^{下面是一个演示:
相关问题 更多 >
编程相关推荐