Standard library / html/template

html/template.Error

Reports a contextual escaping failure with an error code and diagnostic fields. Expected stdout: 'true true\n'.

Formal Syntax & Structure

go syntaxgo
type Error struct {  ErrorCode ErrorCode  Node parse.Node  Name string  Line int  Description string}

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt"  "html/template"  "io")
func main() {  t := template.Must(template.New("x").Parse(`<a href="{{.}}`))  var e *template.Error  fmt.Println(errors.As(t.Execute(io.Discard, "x"), &e), e.ErrorCode == template.ErrEndContext)}
Go Reference