-
-
Notifications
You must be signed in to change notification settings - Fork 20
Allow passing IO to HTML.build #24
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
base: master
Are you sure you want to change the base?
Conversation
|
Actually this doesn't really work, as I think the way to keep this flexible is to change the API a little:
def self.build : String
String.build do |io|
new(io).build do |builder|
with builder yield builder
end
end
end@ysbaddaden does that sound reasonable? Otherwise I'll just patch this in my project to get it working how I need |
|
That sounds reasonable, the buffer shall be a general IO and be created by the We can keep backward compatibility by deprecating the
|
The previous version would always call .to_s on the IO, which would produce incorrect results or at the very least remove any performance gains. This deprecates some methods to make HTML.build the recommended entrypoint.
|
Updated, let me know if that's not what you were thinking |
| String.build do |io| | ||
| new(io).build_impl do |builder| | ||
| with builder yield builder | ||
| end | ||
| end |
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.
Polish:
| String.build do |io| | |
| new(io).build_impl do |builder| | |
| with builder yield builder | |
| end | |
| end | |
| String.build { |io| build(io) } |
| build_impl do | ||
| with self yield self | ||
| end |
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.
Polish: no need to call #build_impl
| build_impl do | |
| with self yield self | |
| end | |
| with self yield self |
For example if you want to write directly to a
TCPSocketor some otherIO.