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

Comments

@icza
Copy link

@icza 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 label Oct 6, 2016
@quentinmit quentinmit added this to the Go1.8 milestone Oct 6, 2016
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 19, 2016

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

@gopherbot gopherbot closed this in 2f7f679 Oct 19, 2016
@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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.