3
HTML 템플릿 '
에 '
탈출 방지 방법 :golang의 HTML 템플릿 '에 '탈출
package main
import (
"html/template"
"os"
)
const tmpl = `<html>
<head>
<title>{{.Title}}</title>
</head>
</html>`
func main() {
t := template.Must(template.New("ex").Parse(tmpl))
v := map[string]interface{}{
"Title": template.HTML("Hello World'"),
}
t.Execute(os.Stdout, v)
}
그것은 출력 :
<html>
<head>
<title>Hello World'</title>
</head>
</html>
원하는 출력 :
<html>
<head>
<title>Hello World'</title>
</head>
</html>
사용중인 js 라이브러리를 제공해주십시오. – Innovation
' 괜찮 으면 그냥 둡니다. – Volker
@Innovation no js, just golang –