From d6602e96d79b7da51b04371ec0bd4e046c8421d4 Mon Sep 17 00:00:00 2001 From: Andreas Kotowicz Date: Thu, 3 Feb 2011 14:02:14 +0100 Subject: [PATCH] keep new lines in html emails --- helpdesk/lib.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helpdesk/lib.py b/helpdesk/lib.py index 893802a2..751948fb 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -85,6 +85,14 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b email_html_base_file = os.path.join('helpdesk', locale, 'email_html_base.html') + + ''' keep new lines in html emails ''' + from django.utils.safestring import mark_safe + + html_txt = context['comment'] + html_txt = html_txt.replace('\r\n', '
') + context['comment'] = mark_safe(html_txt) + html_part = loader.get_template_from_string( "{%% extends '%s' %%}{%% block title %%}%s{%% endblock %%}{%% block content %%}%s{%% endblock %%}" % (email_html_base_file, t.heading, t.html) ).render(context)