Skip to content
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

text/template: not able to redefine template as an empty string #16156

Closed
evandigby opened this issue Jun 22, 2016 · 5 comments
Closed

text/template: not able to redefine template as an empty string #16156

evandigby opened this issue Jun 22, 2016 · 5 comments
Milestone

Comments

@evandigby
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
  • go version go1.6 linux/amd64
  • go version go1.6 darwin/amd64
  • go playground
  1. What operating system and processor architecture are you using (go env)?
  • darwin/amd64
  • linux/amd64
  • go playground
  1. What did you do?

Attempt to redefine a text/template as an empty string using parse, and then executed the template:
https://play.golang.org/p/gotXx8qF3e

  1. What did you expect to see?

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.

  1. What did you see instead?

The execute function returned the following error:
template: test: "test" is an incomplete or empty template; defined templates are: "test"

@ianlancetaylor ianlancetaylor changed the title Not able to redefine text/template as an empty string text/template: not able to redefine template as an empty string Jun 22, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.8 milestone Jun 22, 2016
@jessfraz
Copy link
Contributor

dibs

@gopherbot
Copy link

CL https://golang.org/cl/24380 mentions this issue.

@dmitshur
Copy link
Contributor

dmitshur commented Aug 29, 2016

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:

The typical use is to define a set of root templates that are
then customized by redefining the block templates within.

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 tip.

Edit 2: Not fixed on tip. Filed #16913 for my issue with reproduce steps.

@gopherbot
Copy link

CL https://golang.org/cl/38420 mentions this issue.

gopherbot pushed a commit that referenced this issue Apr 4, 2017
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 <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@gopherbot
Copy link

CL https://golang.org/cl/39594 mentions this issue.

gopherbot pushed a commit that referenced this issue Apr 5, 2017
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 <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/39594
Reviewed-by: Rob Pike <r@golang.org>
lparth pushed a commit to lparth/go that referenced this issue Apr 13, 2017
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 golang#16156 (for real).
Fixes golang#19294.
Fixes golang#19204.

Change-Id: I1cd915c94534cad3116d83bd158cbc28700510b9
Reviewed-on: https://go-review.googlesource.com/38420
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Apr 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants