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: clarify comment and docs for AddParseTree #34695

Closed
greywolve opened this issue Oct 4, 2019 · 4 comments
Closed

text/template: clarify comment and docs for AddParseTree #34695

greywolve opened this issue Oct 4, 2019 · 4 comments
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@greywolve
Copy link
Contributor

greywolve commented Oct 4, 2019

There's an incorrect (and misleading) comment here:

// If the name is the name of this template, overwrite this template.
	nt := t
	if name != t.name {
		nt = t.New(name)
	}

It's probably mean't to be "If the name isn't...", but that's still not easy to read, and should potentially just be dropped? (It's fairly obvious what's going on)

The docs could be made more accurate instead:

AddParseTree adds parse tree for template with given name and associates it with t.
If the template does not already exist, it will create a new one.
If the template does exist, it will be replaced.

Should potentially be:

AddParseTree adds parse tree for template with given name and associates it with t.
If the template does not already exist, it will create a new one.
If the template does exist, it will be replaced, unless the given name matches the template's name.
@andybons
Copy link
Member

andybons commented Oct 4, 2019

Seems reasonable. @robpike in case I’m missing something.

@andybons andybons added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Oct 4, 2019
@andybons andybons added this to the Unplanned milestone Oct 4, 2019
@kumar1202
Copy link

Can I take a look on this ?
I am starting out with open source.

@gopherbot
Copy link

Change https://golang.org/cl/199139 mentions this issue: text/template: remove an incorrect comment and clarify docs for AddParseTree

@greywolve
Copy link
Contributor Author

@kumar1202 already submitted a fix, but thanks for the offer. :)

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

No branches or pull requests

4 participants