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

added support for HTML comments #68 #71

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Conversation

whisk
Copy link
Contributor

@whisk whisk commented Nov 8, 2023

Issue: #68

@whisk whisk mentioned this pull request Nov 8, 2023
Copy link
Owner

@chasefleming chasefleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Just two minor notes. Thanks so much for the issue creation and work on this.

@@ -62,6 +62,16 @@ func (t TextNode) Render() string {
return string(t)
}

type CommentNode string

func (c CommentNode) RenderTo(builder *strings.Builder) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great implementation of the CommentNode! One small suggestion for optimization:

func (c CommentNode) RenderTo(builder *strings.Builder) {
	builder.WriteString("<!-- ")
	builder.WriteString(string(c))
	builder.WriteString(" -->")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this performance tip. Fixed.

builder.WriteString("<!-- " + string(c) + " -->")
}

func (c CommentNode) Render() string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we can follow the same pattern as the Element.Render:

func (c CommentNode) Render() string {
	var builder strings.Builder
	c.RenderTo(&builder)
	return builder.String()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Owner

@chasefleming chasefleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@chasefleming chasefleming merged commit 1fb46d2 into chasefleming:main Nov 10, 2023
1 check passed
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.

2 participants