Yielding in a Haml helper - wrong block being passed in production mode

261 views
Skip to first unread message

scottwb

unread,
Jul 25, 2011, 3:59:53 PM7/25/11
to Haml
I am seeing what I think is a bug in Haml that only happens in
production environments. In short, a simple helper like:

def pass_thru(&block)
yield
end

works as I would expect in development mode, but in production mode,
it seems to be yielding the outer block that contains the call to the
helper, not the block indented underneath the call to the helper.
However, writing that helper like this works fine:

def pass_thru(&block)
haml_concat(capture_haml(&block))
end

I have created a bare-bones Rails app that demonstrates this, along
with a README that describes more detail: https://github.com/scottwb/haml-block-bug

Am I perhaps misunderstanding the use of `yield` in a helper being
called from Haml? I am pretty certain that this technique worked with
Haml 3.0 and earlier. Is there a better way to do what I am trying to
do here?

Thanks,
-Scott

SimonC

unread,
Nov 24, 2011, 6:34:27 PM11/24/11
to ha...@googlegroups.com
Hi Scott,

I've been experiencing exactly the same issue - and like you, only in production. Did you ever resolve this, or are you still using the haml_concat(capture_haml(...)) workaround? I was about to submit an issue to the github repo when I happened across this thread, so would be interested to hear if there was any resolution...

Cheers,
Simon

scottwb

unread,
Nov 24, 2011, 7:55:42 PM11/24/11
to Haml
I'm still using that workaround. I never came to any resolution or
heard anything from anyone else on the subject, and sorta moved on
since I had a working solution and more pressing things. I might go
back and take a look at my code now and at least start tracking the
issue you filed.
Reply all
Reply to author
Forward
0 new messages