去template.ExecuteTemplate包括html

去template.ExecuteTemplate包括html,第1张

去template.ExecuteTemplate包括html

将您的

[]byte
或转换
string
类型
template.HTML
(在此处记录)

p.Body = template.HTML(s) // where s is a string or []byte

然后,在您的模板中,只需:

{{.Body}}

它将被打印而不会逃脱

编辑

为了能够在页面正文中包含HTML,您需要更改

Page
类型声明:

type Page struct {    Title string    Body  template.HTML}

然后分配给它。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5170091.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-18
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存