There appears to be an issue with using HTTP streaming with HAML projects in rails. It works perfectly if I use ERB instead. Apparently, I'm not the only one with this problem.
It doesn't work with placing stream
at the top of the controller, or with using render :stream => true
in the action.
How can I get HAML and HTTP streaming to play nicely together?
Update: I've opened an issue on the gem's page, here.
This is not yet supported by HAML (source):
HTTP streaming is the sort of thing that would require a substantial set of modifications to the core Haml engine. It's only moderately tricky to get it working even in basic cases, but when you factor in things like the whitespace-eating operators it gets much more difficult.
This isn't something I'm opposed to in theory, but it's also not something that's high on my priority list given the difficulty of implementing it.
The internals of Haml are such that it is indeed writing out to a buffer as it goes along. However, the "standard" API that Rails has traditionally provided for templating languages is a fairly straightforward in-and-out call. I don't think Haml does currently have "streaming support", but its simply more of an API issue than anything else.
I'm curious as to how Rails is plugging into ERB to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With