During refactoring it would be quite handy just to copy part of HAML template and paste it to helper\'s code. Currently in such cases 1) I have to rewrite that part of view from
Haml now has a capture_haml
method that you can use to accomplish this.
def some_helper
capture_haml do
.some_class
= yield
#some-code-after
end
end
some_helper do
%h1 Hello World
end
=>
Hello World
Here is a link with more info on capture_haml
:
http://haml.info/docs/yardoc/Haml/Helpers.html#capture_haml-instance_method