跨越多行的django标签

时间:2018-08-31 01:46:18

标签: django django-templates

我正在阅读django教程,我注意到字符串文本中始终包含\。我以为在django中模拟了\ n ...然后由于某种原因标记将无法正确呈现。

上下文:从生成的模板通过sendgrid发送电子邮件 例如:

{% load i18n %}{% autoescape off %}
{% trans "Hi" %} {{ user.get_username }},

{% trans "We've received a request to reset your password. If you didn't 
make\ this request, you can safely ignore this email. Otherwise, click the 
button\ below to reset your password." %}

{% block reset_link %}
    {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid \
token=token %}
{% endblock reset_link %}
{% endautoescape %}

在电子邮件中找到了这个

{%trans“我们已收到重置密码的请求。如果您没有输入\ 此请求,您可以放心地忽略此电子邮件。否则,请点击按钮\ 请重设密码。“%}

http://127.0.0.1:8000 {%url'password_reset_confirm'uidb64 = uid \ token = token%}

但这可以正确显示电子邮件:

{% load i18n %}{% autoescape off %}
{% trans "Hi" %} {{ user.get_username }},

{% trans "We've received a request to reset your password. If you didn't 
make this request, you can safely ignore this email. Otherwise, click the 
button below to reset your password." %}

{% block reset_link %}
    {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid   token=token %}
{% endblock reset_link %}
{% endautoescape %}

那么任何人都可以详细说明为什么其他人会这样做吗?因为据我了解,换行是这样完成的:{{value | linebreaksbr}} https://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks

0 个答案:

没有答案