Sha256: 28e6bbc079e9c1aa12e4b7b0b4d17c4b2f6d51c2bfd2eafd47865d84fc9108b8

Contents?: true

Size: 1.23 KB

Versions: 47

Compression:

Stored size: 1.23 KB

Contents

# ===========================================================================
# Project:   Abbot - SproutCore Build Tools
# Copyright: ©2009 Apple Inc.
#            portions copyright @2006-2011 Strobe 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

47 entries across 47 versions & 1 rubygems

Version Path
sproutcore-1.11.0 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.11.0.rc3 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.11.0.rc2 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.11.0.rc1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.10.3.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.10.2 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.10.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.10.0 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.10.0.rc.3 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.10.0.rc.2 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.10.0.rc.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.9.2 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.9.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.9.0 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.8.2.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.8.1 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.8.0 lib/sproutcore/render_engines/erubis.rb
sproutcore-1.7.1.beta-java lib/sproutcore/render_engines/erubis.rb
sproutcore-1.7.1.beta lib/sproutcore/render_engines/erubis.rb
sproutcore-1.6.0.1-java lib/sproutcore/render_engines/erubis.rb