Given an helper like this one
def helper_method(name, &block)
result = block_given? ? capture(&block)
...
result
end
And this HAML view
= raw helper_method do
.content
some html content
result is nil when used with raw. why?
I know how to solve this, there is many way to avoid the situatio开发者_开发技巧n but what I want to know is why I'm loosing the block?
Since you are not using ()
the block is not reaching the helper_method
.
Basically the raw
method is the one getting the block.
try : raw helper_method {}
It's one of the main differences between the do end
and the {}
blocks.
Or use the ()
to prevent the ambiguity.
I'm not sure because i never user haml but don't you need a end tag??
like this:
<%= raw helper_method do %>
<% end %>
?
精彩评论