require 'rubygems' require 'sinatra' require 'erb' helpers do def buffer() @_out_buf end def capture(buffer) pos = buffer.size yield buffer.slice!(pos..buffer.size) end def my_helper(&block) buffer << erb(capture(buffer, &block), :layout => :my_layout) end end template :index do <<-eos
This is the content in the block.
<% end %> eos end template :my_layout do <<-eosThis should be above the content in the block.
<%= yield %>This should be below the content in the block.