<div>
{{.content}}
</div>
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"content": "<p><li>six</li></p>"
})
I need the 'content' is not be as a text , but is be as a html code to be rendered
@takfate the issue is related with html/template, not gin, but here is your solution:
https://play.golang.org/p/_MP_YWpeH1 (runnable)
package main
import (
"html/template"
"os"
)
func main() {
const tpl = `
<body>
{{.Escaped}}
{{.NotEscaped}}
</body>
`
t, _ := template.New("webpage").Parse(tpl)
data := struct {
Escaped string
NotEscaped template.HTML
}{
Escaped: "<b>escaped<b>",
NotEscaped: "<b>not escaped</b>",
}
_ = t.Execute(os.Stdout, data)
}
check https://golang.org/pkg/html/template/#hdr-Typed_Strings for more docs about html/template
Most helpful comment
@takfate the issue is related with
html/template, not gin, but here is your solution:https://play.golang.org/p/_MP_YWpeH1 (runnable)
check https://golang.org/pkg/html/template/#hdr-Typed_Strings for more docs about
html/template