yoake/internal/servetpl/funcmap/xml.go

15 lines
218 B
Go
Raw Normal View History

2022-11-07 04:45:02 -06:00
package funcmap
import (
"bytes"
"encoding/xml"
)
func EscapeXML(s string) (string, error) {
var b bytes.Buffer
if err := xml.EscapeText(&b, []byte(s)); err != nil {
return "", err
}
return b.String(), nil
}