Sha256: 8bc502298f4da059cd8b915a858d5a1df60eab0e3ee117b08c45bec1d604179f

Contents?: true

Size: 1 KB

Versions: 13

Compression:

Stored size: 1 KB

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

13 entries across 13 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090407205609 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.0.20090408130025 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.0.20090416161445 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.0.20090720093355 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.0.20090720202429 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.0.20090721125122 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.126 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.20090721145236 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.20090721145251 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.20090721145280 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.20090721145281 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.20090721145282 lib/sproutcore/helpers/capture_helper.rb
sproutit-sproutcore-1.0.203 lib/sproutcore/helpers/capture_helper.rb