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: document redefinition of templates #17360

Closed
icza opened this issue Oct 6, 2016 · 1 comment
Closed

text/template: document redefinition of templates #17360

icza opened this issue Oct 6, 2016 · 1 comment
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@icza
Copy link

icza commented Oct 6, 2016

Go home page, Go 1.7.1.

Package text/template and html/template provide the same interface. But the documentation of text/template.Parse() and html/template.Parse() are different.

text/template.Parse() leaves out an important fact that it is an error to redefine a non-empty template. html/template.Parse() contains this important fact. But they work the same way.

I believe when {{block}} action was added in Go 1.6 and redefining of templates got allowed, only the doc of html/template.Parse() was updated but not text/template.Parse().

Example code that triggers this error:

template.Must(template.New("").Parse(`{{block "A" "a"}}a{{end}}{{define "A"}}b{{end}}`))

Playground link with text/template: https://play.golang.org/p/PY3zLcCFiu

Playground link with html/template: https://play.golang.org/p/UeQk4D3tcB

@quentinmit quentinmit changed the title Documentation inconsistency between text/template and html/template text/template: document redefinition of templates Oct 6, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 6, 2016
@quentinmit quentinmit added this to the Go1.8 milestone Oct 6, 2016
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Oct 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants