yoake/internal/servetpl/funcmap/escape.go

20 lines
295 B
Go
Raw Normal View History

2022-11-07 04:45:02 -06:00
package funcmap
import (
"bytes"
"encoding/xml"
2022-11-20 12:05:14 -06:00
"net/url"
2022-11-07 04:45:02 -06:00
)
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
}
2022-11-20 12:05:14 -06:00
func EscapeQuery(s string) string {
return url.QueryEscape(s)
}