From 24b26a8a87226a84377623dfe18f32dbbbc6648c Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 28 Jan 2024 22:27:28 +0100 Subject: [PATCH] replacing n with
--- modules/structs/mail.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/structs/mail.go b/modules/structs/mail.go index 87fd5a5..d284206 100644 --- a/modules/structs/mail.go +++ b/modules/structs/mail.go @@ -134,6 +134,18 @@ func (m *Mail) RenderTemplate() (htmlBody, textBody string, err error) { htmlBuf := new(bytes.Buffer) textBuf := new(bytes.Buffer) + fmt.Println("BODY DATA", m.BodyData) + + // parse body data to new map to avoid changing the original map and then replace all \n with
+ + bodyData := make(map[string]interface{}) + + for key, value := range m.BodyData.(map[string]interface{}) { + bodyData[key] = strings.ReplaceAll(value.(string), "\n", "
") + } + + m.BodyData = bodyData + if err := htmlTemplate.Execute(htmlBuf, m.BodyData); err != nil { return "", "", err }