-
Notifications
You must be signed in to change notification settings - Fork 18k
text/template: not able to redefine template as an empty string #16156
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
Comments
dibs |
CL https://golang.org/cl/24380 mentions this issue. |
I ran into this as well, and I had a hard time figuring out if this was a bug or intended behavior, because when I tried to find documentation for template redefinition, I couldn't. It seems to be mentioned in passing on https://golang.org/pkg/text/template/#hdr-Actions and nowhere else:
Glad to see it was indeed a bug and is already fixed. Edit: Actually, what I ran into may be slightly different (but definitely related). I'll have to test to see if it has been fixed by this change on Edit 2: Not fixed on |
CL https://golang.org/cl/38420 mentions this issue. |
This was a subtle bug introduced in the previous release's fix for issue 16156. The definition of empty template was broken, causing the answer to depend on the order of templates in the map. Fixes #16156 (for real). Fixes #19294. Fixes #19204. Change-Id: I1cd915c94534cad3116d83bd158cbc28700510b9 Reviewed-on: https://go-review.googlesource.com/38420 Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
CL https://golang.org/cl/39594 mentions this issue. |
This was a subtle bug introduced in the previous release's fix for issue 16156. The definition of empty template was broken, causing the answer to depend on the order of templates in the map. Fixes #16156 (for real). Fixes #19294. Fixes #19204. Change-Id: I1cd915c94534cad3116d83bd158cbc28700510b9 Reviewed-on: https://go-review.googlesource.com/38420 Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-on: https://go-review.googlesource.com/39594 Reviewed-by: Rob Pike <[email protected]>
Please answer these questions before submitting your issue. Thanks!
go version
)?go env
)?Attempt to redefine a text/template as an empty string using parse, and then executed the template:
https://play.golang.org/p/gotXx8qF3e
I expected the template to successfully execute and produce an empty string.
Alternatively, if it is expected behaviour to not allow redefining as an empty string, I expect an error to be returned on the "Parse" call.
The execute function returned the following error:
template: test: "test" is an incomplete or empty template; defined templates are: "test"
The text was updated successfully, but these errors were encountered: