我将html存储为字符串形式返回的表,我想将其插入到html模板中。目前,它只是呈现为字符串:
例如假设我的myHtmlString
变量值为<h3>Hello</h3>
func (h *handler) buildEmailTemplate() model.myEmailModel {
return model.myEmailModel {
message: myHtmlString
}
}
type myEmailModel {
message: template.HTML '<h1>Hello</h1>'
}
我尝试将这个buildEmailTemplate函数更改为无法解析为template.HTML字符串:
message: template.HTML(myHtmlString)
您可以尝试this。您可以使用“ html / template”
解析预定义的HTML模板