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

Remove extra line between comments and templ code #351

Merged
merged 11 commits into from
Dec 26, 2023

Conversation

edmondwinston
Copy link
Contributor

@edmondwinston edmondwinston commented Dec 21, 2023

What's changed?

This PR adds conditions to check if above a Templ block exists comments before appending new line characters.
Fixes #335.

POC

  • When running fmt:

templ-comment-fmt

  • When running fmt:

templ-comment-generate

@edmondwinston edmondwinston marked this pull request as ready for review December 21, 2023 15:33
@edmondwinston
Copy link
Contributor Author

Your suggestion made it much easier, thank you.

@edmondwinston edmondwinston force-pushed the edmondw/fix-godoc-comments-in-templ branch from 95c6931 to cfd8275 Compare December 21, 2023 16:10
@edmondwinston
Copy link
Contributor Author

Now looking at the generator's testing part, what would be the alternative for making a new directory, create a .templ file, render it, parse the generated file, then compare the content? I understand the answer is somewhere in the codebase, but do you happen to have it on the top your head?

@a-h a-h merged commit 4580762 into a-h:main Dec 26, 2023
4 checks passed
@a-h
Copy link
Owner

a-h commented Dec 26, 2023

Thanks for the PR!

On the generator testing, I'm not sure I follow what you're looking to test. There's already a test in the CI that ensures that all _templ.go files are up-to-date.

@edmondwinston
Copy link
Contributor Author

@a-h

I meant to add test cases to make sure that the generated comments would also not have that extra line break, for hover docs purpose. It's fine for now, but just to make sure it won't, I think.

@a-h
Copy link
Owner

a-h commented Dec 26, 2023

I'm very sorry, but I'm still not understanding the test scenario. If you're going to follow up with some extra tests, brilliant, I'm sure that will explain it more precisely than English can. 😁

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 this pull request may close these issues.

Comments inside .templ files above templ component get an extra line
2 participants