-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
html/template: "no such template" error after use of Clone #17735
Comments
@rhysh I'm happy to poke around, since that's my commit. Bit hard without a repro, though. |
Thanks @cespare . I agree that not much can be done without a repro, and unfortunately I'm not able to share the application code. Maybe someone else will encounter the issue and be able to extend the report... There is a place within html/template where a template's name can be overwritten, in go/src/html/template/escape.go Line 764 in 3be166d
It seems like there are parts of html/template that assume that the templates they can access are not accessible by external code. The change to Clone's behavior seems to have disrupted that implicit invariant. |
I've got a reproducer now, @cespare ! Critical to the failure is that the template named "title" is invoked within an html
|
Thanks for filing these. I've been seeing some |
CL https://golang.org/cl/33210 mentions this issue. |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
I have an application that sets up and executes some templates. The program starts with a New template, sets a FuncMap via Funcs, and then it calls Parse with a base template. The text of the base template uses the
template
keyword to invoke some templates—it also uses thedefine
keyword to specify default implementations of the templates it invokes.Then the program calls Clone on that template a few separate times, calls Parse with template text that includes re-definitions of the templates invoked by the base template, and then calls Execute on the resulting template.Template values.
What did you expect to see?
With go1.7.3, the program executes its templates successfully.
What did you see instead?
With go version
devel +3be166d Tue Nov 1 22:44:31 2016 +0000
, executing the template fails withThe text of the template includes
{{ define "title" }}{{ end }}
and{{ template "title" . }}
.I've bisected this to cd2c9df,
html/template: fix Clone so that t.Lookup(t.Name()) yields t
.I can work around the bug by inserting a layer of
t = template.Must(t.New("foo").Parse(""))
right before the call to Clone.I haven't been able to reduce this to a minimal test case. Below is code that does not reproduce the bug, but is similar in shape to what the application does.
The text was updated successfully, but these errors were encountered: