Skip to content

html/template: Parsing invalid templates with no actions should fail-fast #52906

Open
@josharian

Description

@josharian

Run:

package main

import (
	"html/template"
	"io"
	"log"
)

func main() {
	t := template.Must(template.New("errmsg").Parse(`<textarea/>`))
	err := t.Execute(io.Discard, nil)
	log.Print(err)
}

https://go.dev/play/p/oiAIres95vU

Result:

2009/11/10 23:00:00 html/template:errmsg: ends in a non-text context: {stateRCDATA delimNone urlPartNone jsCtxRegexp attrNone elementTextarea <nil>}

That error message reads more like an internal debugging message than something intended for users. It took me a while to narrow down the source of the problem.

cc @empijei @kele

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions