Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
module CaptureHelper def capture_erb(*args, &block) buffer = eval('_erbout', block.binding) capture_erb_with_buffer(buffer, *args, &block) end alias_method :capture, :capture_erb alias_method :capture_block, :capture_erb def capture_erb_with_buffer(buffer, *args, &block) pos = buffer.length block.call(*args) # extract the block data = buffer[pos..-1] # replace it in the original with empty string buffer[pos..-1] = '' data end end # module CaptureHelper Webby::Helpers.register(CaptureHelper)
From the Design Piracy series on my blog: