Golang Iris – ctx.ViewData(key,value) alternative for HTML output

@krokite I don’t know if this is the best way, but this is how I do it and it works:

ctx.ViewData("content", template.HTML("<p>This is HTML content.</p><br><h3>Another String</h3>"))

or create a tmpl func:

tmpl := iris.HTML(...)
tmpl.AddFunc("html", func(text string) template.HTML {
	 return template.HTML(text)
})

ctx.ViewData("text", "<p>This is HTML content.</p><br><h3>Another String</h3>")

{{html .text}}

Don’t forget to import the "html/template" package.

https://github.com/kataras/iris/issues/836

Share and Enjoy !

0Shares
0 0