Sha256: 18be1028b1d728678b2d219c32b549b15dd704794a7f405099967dc7048558c4

Contents?: true

Size: 1023 Bytes

Versions: 35

Compression:

Stored size: 1023 Bytes

Contents

# ===========================================================================
# Project:   Abbot - SproutCore Build Tools
# Copyright: ©2009 Apple Inc.
#            portions copyright @2006-2009 Sprout Systems, Inc.
#            and contributors
# ===========================================================================

module SC

  module Helpers

    module CaptureHelper

      # Captures the resulting value of the block and returns it
      def capture(*args, &block)
        self.renderer ? self.renderer.capture(args, &block) : block.call(*args).to_s
      end

      # executes the passed block, placing the resulting content into a variable called
      # @content_for_area_name.  You can insert this content later by including this
      # variable or by calling yield(:area_name)
      #
      def content_for(name, &block)
        eval "@content_for_#{name} = (@content_for_#{name} || '') + (capture(&block) || '')"
        return '' # incase user does <%= content_for ... %>
      end

    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.20090721145285 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.4-java lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.4 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.3.1 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.3-java lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.3 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.2-java lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.2 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.1-java lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.1 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.0-java lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.0 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.0.rc.5 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.0.rc.4 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.0.rc.3 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.0.rc.2 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.4.0.rc lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.0.1049.pre.2 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.0.1049.pre.1 lib/sproutcore/helpers/capture_helper.rb
sproutcore-1.0.1046 lib/sproutcore/helpers/capture_helper.rb