-
Notifications
You must be signed in to change notification settings - Fork 7
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
Streaming HTML #13
Comments
Well, the initial implementation wrote directly to the output writer without intermediate buffering, but I had to change it in v0.5.0 in order to support layouts (where you need to call I'm not very happy about that either, but I thought this was good enough for a library like this one - I didn't think anyone would want to stream the output with RazorBlade. I'll think about how to improve it. In the meantime, maybe you could use v0.4.4 as a workaround if you don't need support for layouts. |
I released v0.6.0 which adds a Note that you'll have to write I may add an option to disable buffering and write directly to the output stream, but I'll leave that for a future version. |
Assuming you were willing to break compatibility and to drop support for |
Well, I'm not willing to remove a feature such as layouts, but I'm still not happy about how it forced me to buffer contents. I think I'll add an option to add streaming back - the latest changes should make that easier. I'm not familiar with RazorSlices do I don't understand what you mean, I'll take a look. |
Ok I've read the RazorSlices code and I see what you meant by having to drop support for I won't drop support for Basically, RazorBlade needs to know if there's a layout before it emits anything to
So here are my first thoughts. Which would be your preferred solution, or do you have other ideas? |
1 sounds fine to me. Presumably it would be possible to build your own RazorSlices-style streaming layout mechanism on top of it (by not implementing the interface) if you wanted to. |
I think I'll go with something closer to 2, which is essentially a simplified version of 1. When rendering starts, an equivalent of That would be pretty straightforward, wouldn't require an additional interface, and streaming would be enabled by default unless there's a layout. |
There was an interesting HN post recently on streaming HTML without JavaScript, and it got me thinking about how to flush partially rendered HTML in RazorBlade.
Basically, the idea is that the HTML rendered up to the "FLUSH" marker is sent immediately because the content after might take awhile to render:
If RazorBlade used the output stream directly I could invoke it with a
TextWriter
whose stream was directly attached to a network socket and then directly call Flush/FlushAsync:But it looks like you first render to a string builder, then write that to the output. I think this is a bit outside of your original use case, but is there a compelling reason to not render directly to the given TextWriter?
The text was updated successfully, but these errors were encountered: