Sha256: ae7b89c31b082412f52ba5cacef577e83ea6c9d130f566b25c162ec8a1c9eacb

Contents?: true

Size: 1.24 KB

Versions: 18

Compression:

Stored size: 1.24 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

18 entries across 18 versions & 1 rubygems

Version Path
sproutcore-1.4.4-java lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.4 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.3.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.3-java lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.3 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.2-java lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.2 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.1-java lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.0-java lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.0 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.0.rc.5 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.0.rc.4 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.0.rc.3 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.0.rc.2 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.4.0.rc lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1049.pre.2 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.0.1049.pre.1 lib/sproutcore/render_engines/erubis.rb