github.com/golazy/golazy@v0.0.7-0.20221012133820-968fe65a0b65/lazyview/nodes/text.go (about) 1 package nodes 2 3 import ( 4 "html" 5 "io" 6 ) 7 8 // Text represents a TextNode 9 type Text string 10 type Raw string 11 12 // WriteTo writes the current string to the writer w without any escape 13 func (t Raw) WriteTo(w io.Writer) (int64, error) { 14 n, err := w.Write([]byte(t)) 15 return int64(n), err 16 } 17 18 // WriteTo writes the current string to the writer w while escapeing html with https://godocs.io/html#EscapeString 19 func (t Text) WriteTo(w io.Writer) (int64, error) { 20 n, err := w.Write([]byte(html.EscapeString(string(t)))) 21 return int64(n), err 22 }