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

Comments

@greywolve
Copy link
Contributor

@greywolve 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 andybons commented Oct 4, 2019

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

@andybons andybons added this to the Unplanned milestone Oct 4, 2019
@kumar1202
Copy link

@kumar1202 kumar1202 commented Oct 4, 2019

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

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 5, 2019

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

@greywolve greywolve commented Oct 5, 2019

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

@gopherbot gopherbot closed this in ba4593a Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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