Standard library / html/template

html/template.ErrPredefinedEscaper

A predefined escaper occurs in a context where it is disallowed. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
const ErrPredefinedEscaper ErrorCode

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt"  "html/template"  "io")
func main() {  t := template.Must(template.New("x").Parse("<div class={{. | html}}>x</div>"))  var e *template.Error  err := t.Execute(io.Discard, nil)  fmt.Println(errors.As(err, &e) && e.ErrorCode == template.ErrPredefinedEscaper)}
Go Reference