Standard library / html/template
html/template.JSEscaper()
Formats arguments and escapes JavaScript string content. Expected stdout: 'a\\"b\n'.
Formal Syntax & Structure
go syntaxgo
func JSEscaper(args ...any) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| args | ...any | Values formatted before escaping. |
Return Value
string
Formats arguments and escapes JavaScript string content.
Working Example
Example Snippetgo
package main
import ( "fmt" "html/template")
func main() { fmt.Println(template.JSEscaper(`a"b`)) }