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

vscode: Syntax highlighting for inline method components #566

Closed
alehechka opened this issue Feb 28, 2024 · 6 comments · Fixed by templ-go/templ-vscode#38
Closed

vscode: Syntax highlighting for inline method components #566

alehechka opened this issue Feb 28, 2024 · 6 comments · Fixed by templ-go/templ-vscode#38

Comments

@alehechka
Copy link
Contributor

Overview

@Ra0k had opened #561 asking about support for inline method components which has been added in the main branch but not released. I wanted to try this out myself and noticed that the VSCode extension does not support syntax highlighting for this type of expression. I can take a look at this and get a PR opened for it.

Example from #56

package main

type Data struct {
	message string
}

templ (d Data) Method() {
	<div>{ d.message }</div>
}

templ Hello() {
	@Data{
		message: "You can implement methods on a type.",
	}.Method()
}
@alehechka alehechka changed the title vscode: Syntax highling for inline method components vscode: Syntax highlighting for inline method components Feb 28, 2024
@alehechka
Copy link
Contributor Author

PR opened: templ-go/templ-vscode#38

@joerdav
Copy link
Collaborator

joerdav commented Feb 28, 2024

@alehechka thanks for the PR. I'm not sure if this is a regression but it looks like now non-function components are not rendered properly:

templ higherOrderTemplate(a, b templ.Component) {
	<div class="left">
		@a
	</div>
	<div class="right">
		@b
	</div>
}

image

@alehechka
Copy link
Contributor Author

@joerdav checking this on v0.0.21, it appears to have the same lack of syntax highlighting. So I don't believe this to be a regression. The syntax regex for import-expressions currently relies on @functionName( to begin capture. This PR basically just makes @structName{ also a valid begin capture.

If you want, I can add syntax highlighting support for non-function components to this PR or open a new one for just that addition?

@joerdav
Copy link
Collaborator

joerdav commented Feb 28, 2024

If you want, I can add syntax highlighting support for non-function components to this PR or open a new one for just that addition?

Let's do a separate PR, don't want to block your good work any longer!

@alehechka
Copy link
Contributor Author

Let's do a separate PR, don't want to block your good work any longer!

Sounds good to me. I'll have time after work to take a look at it.

@alehechka
Copy link
Contributor Author

@joerdav, I opened a PR for this: templ-go/templ-vscode#39. It has one open question about the syntax highlighting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants