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

dmitshur opened this issue Aug 29, 2016 · 2 comments

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

dmitshur opened this issue Aug 29, 2016 · 2 comments


Copy link

@dmitshur dmitshur commented Aug 29, 2016

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

Copy link
Member Author

@dmitshur dmitshur commented Aug 29, 2016

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 label Oct 10, 2016
Copy link

@gopherbot gopherbot commented Oct 19, 2016

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