golang iris html/temple

在使用golang的模板语法的过程中遇见自动转义问题(或者以我的理解下发的富文本html代码不是template.html类型,而是string类型),需要强制转型

func unescaped(x string) interfacef{}{

  t:=template.New(“”)

  t=t.Funcs(template.FuncMap{“unescaped”:unescaped})

  return template.HTML(x)

}

调用的时候str:=unescaped(st),然后下发str

 

Related Posts

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注