Sha256: 5e8c1d6cc990e0a49ff9858d533e127305b0b9076af384003874fbba8f06bd81

Contents?: true

Size: 1.26 KB

Versions: 17

Compression:

Stored size: 1.26 KB

Contents

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

module SC
  module RenderEngine

    class Erubis
      def initialize(html_context)
        @html_context = html_context
      end

      def compile(input)
        begin
          require 'erubis'
        rescue
          raise "Cannot render ERB file because erubis is not installed. Try running 'sudo gem install erubis' and try again"
        end
        
        ::Erubis::Eruby.new.convert(input)
      end

      def concat(string, binding)
        eval('_buf', binding) << string
      end

      def capture(*args, &block)
        begin
          buffer = eval('_buf', block.binding)
        rescue
          buffer = nil
        end
        
        if buffer.nil?
          block.call(*args).to_s
        else
          pos = buffer.length
          block.call(*args)

          # get emitted data
          data = buffer[pos..-1]

          # remove from buffer
          buffer[pos..-1] = ''

          data
        end
      end
    end

  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.20090721145285 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1046 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1043 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1042 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1037 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1035 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1031 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1030 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1029 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1027 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1028 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1026 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1025 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1024 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1009 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1008 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1003 lib/sproutcore/render_engines/erubis.rb