-
Notifications
You must be signed in to change notification settings - Fork 18k
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
x/tools/gopls: support language features for text/template, html/template #36911
Comments
Change https://golang.org/cl/301493 mentions this issue: |
Change https://golang.org/cl/301493 mentions this issue: |
I was looking into this and noticed that Goland has IDE-level support for this. It requires the use of a comment to specify the embedded type.
I can't see a way to support language features without some sort of "type hint" for template files, so maybe this is something to consider making standard. https://blog.jetbrains.com/go/2018/12/14/go-templates-made-easy/ |
@a-h it actually works quite nice even without these magic comments. I never used them. It has almost everything you expect when working with html templating languages out of the box. |
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>
Has there been any discussion what the default template file extensions should be? I currently see the following suggestions in VS Code:
I think this is not the optimal approach. It would be more flexible to use a single extension to indicate that a file is a Go template with a pattern like AFAIK all template files are text templates for Go with the exception of html. Extension scheme I proposed makes it obvious what the template filename should be and identifies go template files uniquely - |
It should be configurable. In most of projects we used There actually was an issue where I mentioned these concerns @harvastum. It was quite some time ago, it may also be in old repo (which was owned by Microsoft at the moment). |
I agree this is certainly the most flexible, but can VS Code do something like layered syntax parsing where it is able to work with Go template syntax and YAML at the same time without creating a new language definition? |
Yes, it obviously should be configurable. But defaults are powerful. People will use them, they will become convention and at some point, standard. This choice is pretty important. |
This has soaked for a while as an experimental feature, and we should make it default. But it sounds like we should expose some additional configuration before turning it on by default. @pjweinb WDYT? |
what extra configuration? i think there's already an enabling/disabling
option.
…On Fri, Nov 5, 2021 at 10:45 AM findleyr ***@***.***> wrote:
This has soaked for a while as an experimental feature, and we should make
it default.
But it sounds like we should expose some additional configuration before
turning it on by default. @pjweinb <https://github.com/pjweinb> WDYT?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#36911 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJIAIZ26MO3HCRSKQVRQLDUKQQ4BANCNFSM4KN6JELA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Just the file extension(s). Per @inliquid's #36911 (comment):
FWIW, I've seen all of those, including .tmpl. I think .tmpl or .gohtml is probably fine as a default, but it should be possible for users to configure it for codebases using different file extensions. I suppose this doesn't need to block templates being enabled by default, since users can always disable if it doesn't work for them. @pjweinb does that make sense? Any other concerns before moving this out of experimental? |
i agree that people should be able to set the file extensions. (That
affects both gopls and vscode-go.) I'll do the gopls option when I get back.
…On Fri, Nov 5, 2021 at 5:08 PM findleyr ***@***.***> wrote:
what extra configuration?
Just the file extension(s). Per @inliquid <https://github.com/inliquid>'s #36911
(comment)
<#36911 (comment)>:
It should be configurable. In most of projects we used *.html for go
templates. Once I saw .gohtml. And absolutely never .tmpl.
FWIW, I've seen all of those, including .tmpl. I think .tmpl or .gohtml is
probably fine as a default, but it should be possible for users to
configure it for codebases using different file extensions.
I suppose this doesn't need to block templates being enabled by default,
since users can always disable if it doesn't work for them.
@pjweinb <https://github.com/pjweinb> does that make sense? Any other
concerns before moving this out of experimental?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#36911 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJIAI7XIP2FBC6NS3MYG4DUKR5XDANCNFSM4KN6JELA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Change https://golang.org/cl/363360 mentions this issue: |
See discussion on microsoft/vscode-go#228.
The text was updated successfully, but these errors were encountered: