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: Template redefinition is not documented. #16912

Closed
dmitshur opened this issue Aug 29, 2016 · 2 comments
Closed

text/template: Template redefinition is not documented. #16912

dmitshur opened this issue Aug 29, 2016 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dmitshur
Copy link
Contributor

I believe it may be an issue that template redefinition is not documented.

I only know it's possible to do so because Go 1.6 release notes mentioned it:

Second, the new {{block}} action, combined with allowing redefinition of named templates, provides a ...

(Emphasis mine.)

However, when I read documentation for text/template package, it does not seem to say that it's possible to redefine templates. It mentions this ability in passing, as part of documenting the block action:

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

However, it does not explicitly say anywhere that "it's possible to redefine a named template", nor does it discuss any limitations in doing so.

This may be an issue that can be resolved with a single sentence like "It's possible to redefine a template by defining it again."

This may also be a non-issue if we consider that the ability to redefine templates can be understood to be implicit (i.e., if template redefinition is not explicitly said to be disallowed, then it must be allowed).

Related to #3812 and CL that implements this https://go-review.googlesource.com/#/c/14005/. Its commit message did document this:

Templates may now be redefined,
but in the html/template package they may only be redefined before
the template is executed (and therefore escaped).

The intention is that such inline templates can be redefined by
subsequent template definitions, permitting a kind of template
"inheritance" or "overlay". (See the example for details.)

I think mentioning that in the text/template docs would potentially resolve this issue, if it's an issue.

@dmitshur
Copy link
Contributor Author

This may be an issue in context of #16913. Without this feature being explicitly documented, I found it hard to know whether that odd behavior was intentional or a bug.

@quentinmit quentinmit added this to the Go1.8 milestone Sep 6, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 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
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