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/parse: add CommentNode to the parse tree #34652
Comments
I assume this can only be accepted if #25357 is rejected. |
Why? It's a Go2 proposal, and |
Yes; but if the plan is to eventually hide/remove the |
/cc @robpike for thoughts about supporting template-manipulation programs a la gofmt by adding CommentNode. |
I think it’s needed for gopls as well - #36911 |
I would have made the package internal had that been an option at the time, but I couldn't, and now it's being used by software that wouldn't have been able to, making it harder to maintain and de facto subject to the compatibility rules. From my position, that is a tale of woe. Hyrum's law, which was a problem before Hyrum was even born, bites again. On the other hand, people do depend on it and the uses are mostly reasonable, so we should probably accept this and close #25357. I do think though that we should keep the comment that discourages its use, to give us some leverage against unreasonable requests for change. |
Based on the discussion above, then, this sounds like a likely accept. |
Sounds good to me. Should we reject #25357, then? In the past few years it's been made clear that Go2 will be an incremental process instead of one big set of breaking changes, so it seems unlikely to me that we'd hide an entire package at any point. |
Thanks for the feedback. I would be happy to add this once it's accepted.
IMHO, the |
No change in consensus, so accepted. Yes, I think we can reject #25357 as well. |
If this has been accepted, then I take it there's no interest in marking text/template/parse as deprecated? |
Since I already have a working change for this in my fork that I plan to push in the upcoming days, I prefer to take it. Thanks |
Change https://golang.org/cl/229398 mentions this issue: |
The current CL is adding a new |
Change https://golang.org/cl/301493 mentions this issue: |
Change https://golang.org/cl/301493 mentions this issue: |
Following the discussion on #34652 and the proposal of #36911 (gopls), this CL adds an option to skip the function declartion check on parsing, in order to make it possible to parse arbitrary template text files and get their AST. Fixed #38627 Change-Id: Id1e0360fc726b49dcdd49716ce25563ebaae6c10 Reviewed-on: https://go-review.googlesource.com/c/go/+/301493 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Ian Lance Taylor <iant@golang.org>
Change https://golang.org/cl/317269 mentions this issue: |
The proposal as accepted in #34652 named the bit SkipFuncCheck. It was renamed to DeferFuncCheck during the code review on a suggestion by Rob, along with a comment to “defer type checking functions until template is executed,” but this description is not accurate: the package has never type-checked functions, only verified their existence. And the effect of the bit in this package is to eliminate this check entirely, not to defer it to some later time. I was writing code using this new bit and was very confused about when the "type checking" was being deferred to and how to stop that entirely, since in my use case I wanted no checks at all. What I wanted is what the bit does, it just wasn't named accurately. Rename back to SkipFuncCheck. Change-Id: I8e62099c8a904ed04521eb5b86155290f6d5b12f Reviewed-on: https://go-review.googlesource.com/c/go/+/317269 Trust: Russ Cox <rsc@golang.org> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Change https://golang.org/cl/311569 mentions this issue: |
Documents the newly added mode that skips type checking functions as per CL 301493. Fixes #46025 For #34652 For #44513 For #38627 Change-Id: I56c4f65924702a931944796e39f43cfeb66abc8a Reviewed-on: https://go-review.googlesource.com/c/go/+/311569 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Michael Knyszek <mknyszek@google.com>
Currently, template comments are ignored in the lexer and do not show in the parse tree.
It makes it difficult to build tools around templates (like code formatter) without re-implementing the parser.
My proposal is to add a CommentNode to the parse tree and skip it in the executer.
The text was updated successfully, but these errors were encountered: