{'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
如何显示带有这些换行符的模板?
{{quotes | withlinebreaks\n}}
最佳答案
使用 linebreaks
过滤器。
例如:
{{ value|linebreaks }}
如果value是
Joel\nis a slug
,则输出将是<p>Joel<br />is a slug</p>
。