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
Fixes #377, renders the html that can be manipulated with writer #399
Fixes #377, renders the html that can be manipulated with writer #399
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.
Thanks for the PR, it looks great! Left just a couple of minor things, if you have the time to address them, great, otherwise I can take care of those later this week.
utilities.go
Outdated
@@ -57,6 +58,19 @@ func nodeName(node *html.Node) string { | |||
} | |||
} | |||
|
|||
// Render renders the html of the first element from selector and writes it to the writer. | |||
// It behaves similar to OuterHtml but takes io.Writer as input. |
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.
// It behaves similar to OuterHtml but takes io.Writer as input. | |
// It behaves the same as OuterHtml but writes to w instead of returning the 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.
Makes sense! Done
utilities_test.go
Outdated
@@ -81,48 +124,18 @@ func TestNodeNameMultiSel(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestOuterHtml(t *testing.T) { | |||
func TestRender(t *testing.T) { |
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.
Ah yeah, given that this is exactly the same as TestOuterHtml
and that OuterHtml calls Render anyway, it's fine to keep just TestOuterHtml
.
utilities.go
Outdated
if err := html.Render(w, n); err != nil { | ||
return err | ||
} | ||
return nil |
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.
Oh one more thing, this (lines 68-71) could be simplified to just return html.Render(w, n)
.
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.
done!
Thanks! |
Fixes #377 issue