Standard library / text/template

text/template.HTMLEscape()

Writes HTML-escaped bytes; this helper is not a complete context-aware renderer. Expected stdout: '<b>&\n'.

Formal Syntax & Structure

go syntaxgo
func HTMLEscape(w io.Writer, b []byte)

Parameters & Attributes

NameTypeDescription
wio.WriterDestination writer.
b[]byteBytes to escape.

Working Example

Example Snippetgo
package main
import (  "fmt"  "os"  "text/template")
func main() { template.HTMLEscape(os.Stdout, []byte("<b>&")); fmt.Println() }
Go Reference