I was looking at how content_for works and observed the block.call
in the capture_erb_with_buffer
method. It apparently magically writes to the buf
Simply:
calling yield in a method executes code that was passed to the method via a block.
For instance
def my_method
yield
end
my_method { puts "Hello" }
my_method { puts "World" }
these 5 lines will produce the following output to the screen
Hello
World
See the following page for a nice discussion of yield in Ruby: Ruby Yield