[Go] template显示html不要被转码

如果直接分配到模板中html的字符串 , 会被转码 , 需要强制把字符串转换成template.HTML类型 , 例如下面这样:

    header := tools.FileGetContent("html/header.html")
    html := tools.FileGetContent("html/list.html")
    t, _ := template.New("list").Parse(html)
    render.(*tools.IndexData).Header=template.HTML(header)
    t.Execute(w, render)
IndexData结构体的 Header属性是  template.HTML类型的
template.HTML
原文地址:https://www.cnblogs.com/taoshihan/p/12943549.html