replacing n with <br>
parent
32348e92a8
commit
24b26a8a87
|
@ -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 <br>
|
||||
|
||||
bodyData := make(map[string]interface{})
|
||||
|
||||
for key, value := range m.BodyData.(map[string]interface{}) {
|
||||
bodyData[key] = strings.ReplaceAll(value.(string), "\n", "<br>")
|
||||
}
|
||||
|
||||
m.BodyData = bodyData
|
||||
|
||||
if err := htmlTemplate.Execute(htmlBuf, m.BodyData); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue