-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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(" -->")
}
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
Issue: #68