Sha256: 692ee5d350b511a410c42bb5d9a0aaf4d281f7ae4a096c97a3fce6c0c1c40fe3

Contents?: true

Size: 796 Bytes

Versions: 8

Compression:

Stored size: 796 Bytes

Contents

module Munge
  module Helpers
    module Capture
      def capture(&block)
        if block.binding.local_variable_defined?(:_erbout)
          original_erbout = block.binding.local_variable_get(:_erbout)
          block.binding.local_variable_set(:_erbout, "")

          captured_text = yield

          block.binding.local_variable_set(:_erbout, original_erbout)

          captured_text
        else
          yield
        end
      end

      def append_to_erbout(block_binding, text)
        if block_binding.local_variable_defined?(:_erbout)
          original_erbout = block_binding.local_variable_get(:_erbout)

          updated_erbout = original_erbout + text

          block_binding.local_variable_set(:_erbout, updated_erbout)
        end

        text
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
munge-0.18.0 lib/munge/helpers/capture.rb
munge-0.17.0 lib/munge/helpers/capture.rb
munge-0.16.0 lib/munge/helpers/capture.rb
munge-0.15.1 lib/munge/helpers/capture.rb
munge-0.15.0 lib/munge/helpers/capture.rb
munge-0.14.0 lib/munge/helpers/capture.rb
munge-0.13.0 lib/munge/helpers/capture.rb
munge-0.12.0 lib/munge/helpers/capture.rb