HAML doesn't work with HTTP streaming. #436

Open
juliosantos opened this Issue Sep 23, 2011 · 34 comments

Comments

Projects
None yet
@juliosantos

There appears to be an issue with using HTTP streaming with HAML projects in rails. It works perfectly if I use ERB instead.

It doesn't work with placing stream at the top of the controller, or with using render :stream => true in the action.

@gunn

This comment has been minimized.

Show comment
Hide comment
@gunn

gunn Oct 3, 2011

Would really love to see this.

gunn commented Oct 3, 2011

Would really love to see this.

@ChristianPeters

This comment has been minimized.

Show comment
Hide comment
@ChristianPeters

ChristianPeters Nov 2, 2011

+1

This is definitely a show stopper.

+1

This is definitely a show stopper.

@troessner

This comment has been minimized.

Show comment
Hide comment
@troessner

troessner Nov 11, 2011

Any updates on this? This is kind of a critical issue - any way we can assist?

Any updates on this? This is kind of a critical issue - any way we can assist?

@micha-f

This comment has been minimized.

Show comment
Hide comment
@micha-f

micha-f Nov 11, 2011

+1

This would be awesome.

micha-f commented Nov 11, 2011

+1

This would be awesome.

@incubus

This comment has been minimized.

Show comment
Hide comment

incubus commented Nov 14, 2011

+1

@jgarber

This comment has been minimized.

Show comment
Hide comment

jgarber commented Nov 17, 2011

+1

@troessner

This comment has been minimized.

Show comment
Hide comment
@troessner

troessner Nov 17, 2011

@nex3 we need you..:-/

@nex3 we need you..:-/

@nex3

This comment has been minimized.

Show comment
Hide comment
@nex3

nex3 Nov 17, 2011

Collaborator

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.

Collaborator

nex3 commented Nov 17, 2011

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.

@digidanny

This comment has been minimized.

Show comment
Hide comment

+1

@JonasNielsen

This comment has been minimized.

Show comment
Hide comment

+1

@mhenrixon

This comment has been minimized.

Show comment
Hide comment
@mhenrixon

mhenrixon Jan 22, 2012

+1 what would be required for this to work?

+1 what would be required for this to work?

@gunn

This comment has been minimized.

Show comment
Hide comment
@gunn

gunn Jan 23, 2012

@nex3 would it be easier to support just for ugly mode then?

gunn commented Jan 23, 2012

@nex3 would it be easier to support just for ugly mode then?

@ROFISH

This comment has been minimized.

Show comment
Hide comment

ROFISH commented Jan 24, 2012

+1

@nex3

This comment has been minimized.

Show comment
Hide comment
@nex3

nex3 Jan 24, 2012

Collaborator

@mhenrixon There would need to be some abstraction over the current output buffer that figured out when it was safe to flush the stream, taking into account all possible manipulations that may be done in the Haml code. This would also need to avoid negatively affecting the performance of non-streaming mode, as well as not being too much slower in streaming mode.

@gunn No; the whitespace nuke operators still need to work on user-generated strings, which aren't necessarily controlled by the :ugly flag.

Collaborator

nex3 commented Jan 24, 2012

@mhenrixon There would need to be some abstraction over the current output buffer that figured out when it was safe to flush the stream, taking into account all possible manipulations that may be done in the Haml code. This would also need to avoid negatively affecting the performance of non-streaming mode, as well as not being too much slower in streaming mode.

@gunn No; the whitespace nuke operators still need to work on user-generated strings, which aren't necessarily controlled by the :ugly flag.

@mhenrixon

This comment has been minimized.

Show comment
Hide comment
@mhenrixon

mhenrixon Jan 24, 2012

@nex3 I don't have an issue with switching over to ERB for when I have really large views with a lot of content though. Might as well keep this bugfree and simple and use the right tool (ERB) for the job (when it's needed). Thanks for the explanation.

@nex3 I don't have an issue with switching over to ERB for when I have really large views with a lot of content though. Might as well keep this bugfree and simple and use the right tool (ERB) for the job (when it's needed). Thanks for the explanation.

@zak

This comment has been minimized.

Show comment
Hide comment

zak commented Feb 9, 2012

+1

@ExistsAndIs1

This comment has been minimized.

Show comment
Hide comment
@ExistsAndIs1

ExistsAndIs1 Feb 15, 2012

+1 , would love to have it

+1 , would love to have it

@benone

This comment has been minimized.

Show comment
Hide comment

benone commented Mar 18, 2012

+1

@tolsen

This comment has been minimized.

Show comment
Hide comment

tolsen commented Mar 28, 2012

+1

@mariovisic

This comment has been minimized.

Show comment
Hide comment

+1

@jhilden

This comment has been minimized.

Show comment
Hide comment

jhilden commented Apr 22, 2012

+1

@tatyree

This comment has been minimized.

Show comment
Hide comment

tatyree commented Apr 24, 2012

+1

@skorfmann

This comment has been minimized.

Show comment
Hide comment

+1

@Bertg

This comment has been minimized.

Show comment
Hide comment
@Bertg

Bertg May 29, 2012

I wonder if there is a way for this to be possible:

  • Use a ERB layout
  • Use haml template when streaming is not needed
  • Use erb template when streaming (allow non-streaming HAML partials inside)

This would allow us to still do streaming when needed, and have HAML for most partials.

Would this be difficult to implement? Would it work if HAML just pretend to be streaming compatible?

EDIT:

  • if both the layout and template are ERB then streaming will happen, even with HAML partials
  • Forcing the usage of streaming with a HAML template in an ERB layout works

Bertg commented May 29, 2012

I wonder if there is a way for this to be possible:

  • Use a ERB layout
  • Use haml template when streaming is not needed
  • Use erb template when streaming (allow non-streaming HAML partials inside)

This would allow us to still do streaming when needed, and have HAML for most partials.

Would this be difficult to implement? Would it work if HAML just pretend to be streaming compatible?

EDIT:

  • if both the layout and template are ERB then streaming will happen, even with HAML partials
  • Forcing the usage of streaming with a HAML template in an ERB layout works
@afeld

This comment has been minimized.

Show comment
Hide comment
@afeld

afeld May 29, 2012

@Bertg We use ERB for our layout and main view but HAML for some partials, and streaming works fine up until they are reached. I think it may even send HAML partials as a full chunk but then resume streaming afterwards.

afeld commented May 29, 2012

@Bertg We use ERB for our layout and main view but HAML for some partials, and streaming works fine up until they are reached. I think it may even send HAML partials as a full chunk but then resume streaming afterwards.

@norman

This comment has been minimized.

Show comment
Hide comment
@norman

norman Jun 15, 2012

Member

This is on the roadmap for Haml 4.0, which I hope to release by the end of the year.

Member

norman commented Jun 15, 2012

This is on the roadmap for Haml 4.0, which I hope to release by the end of the year.

@barttenbrinke

This comment has been minimized.

Show comment
Hide comment
@barttenbrinke

This comment has been minimized.

Show comment
Hide comment
@barttenbrinke

barttenbrinke Jul 31, 2012

I've swapped haml for slim. This does have streaming support and also renders all my templates 6 times as fast (yes 6 times!). Automated converting can be done using the haml2slim gem, but that is a bit wonky atm. You should be able to use the slim gem to render the haml templates without converting, but then you'll have to write some rails magic to glue the two together.

I've swapped haml for slim. This does have streaming support and also renders all my templates 6 times as fast (yes 6 times!). Automated converting can be done using the haml2slim gem, but that is a bit wonky atm. You should be able to use the slim gem to render the haml templates without converting, but then you'll have to write some rails magic to glue the two together.

@lephyrius

This comment has been minimized.

Show comment
Hide comment

+1

@marcandre

This comment has been minimized.

Show comment
Hide comment
@marcandre

marcandre Dec 3, 2012

Goodbye haml, hello slim.

Goodbye haml, hello slim.

@norman

This comment has been minimized.

Show comment
Hide comment
@norman

norman Feb 12, 2013

Member

Just a quick FYI, we've decided to change the 3.2 release's number to 4.0 because it included breaking changes, so this feature will now be on the map for version 5.0. 4.0 will be out tomorrow.

Member

norman commented Feb 12, 2013

Just a quick FYI, we've decided to change the 3.2 release's number to 4.0 because it included breaking changes, so this feature will now be on the map for version 5.0. 4.0 will be out tomorrow.

@onurozgurozkan

This comment has been minimized.

Show comment
Hide comment
@jgrevich

This comment has been minimized.

Show comment
Hide comment

👍

@l8on

This comment has been minimized.

Show comment
Hide comment

l8on commented Aug 14, 2014

:+1

@k0kubun k0kubun referenced this issue Feb 19, 2018

Open

Hackathon #979

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment