package main
import (
"github.com/russross/blackfriday/v2"
)
templ mail_body_comp(rcpt_addr string, m mail_obj) {
nthmail.xyz
@mime_type(m.Body[m.PreferedBodyIndex])
}
templ mime_type(b mail_body) {
switch b.MimeType {
case Html:
@body_html(b.Data)
case Markdown:
@body_markdown(b.Data)
case PlainText:
@body_plain(b.Data)
default:
@body_plain(b.Data)
}
}
templ body_plain(s string) {
{ s }
}
templ body_html(s string) {
@templ.Raw(s)
}
templ body_markdown(s string) {
@body_html(string(blackfriday.Run([]byte(s))))
)
}