Sha256: 50e79aa9718976ce9d6a7e3ffde6b4ea695e77724bc5549ee2300e6697807797

Contents?: true

Size: 1.44 KB

Versions: 187

Compression:

Stored size: 1.44 KB

Contents

require 'tilt/erb'
require 'erubis'

module Tilt
  # Erubis template implementation. See:
  # http://www.kuwata-lab.com/erubis/
  #
  # ErubisTemplate supports the following additional options, which are not
  # passed down to the Erubis engine:
  #
  #   :engine_class   allows you to specify a custom engine class to use
  #                   instead of the default (which is ::Erubis::Eruby).
  #
  #   :escape_html    when true, ::Erubis::EscapedEruby will be used as
  #                   the engine class instead of the default. All content
  #                   within <%= %> blocks will be automatically html escaped.
  class ErubisTemplate < ERBTemplate
    def prepare
      @outvar = options.delete(:outvar) || self.class.default_output_variable
      @options.merge!(:preamble => false, :postamble => false, :bufvar => @outvar)
      engine_class = options.delete(:engine_class)
      engine_class = ::Erubis::EscapedEruby if options.delete(:escape_html)
      @engine = (engine_class || ::Erubis::Eruby).new(data, options)
    end

    def precompiled_preamble(locals)
      [super, "#{@outvar} = _buf = String.new"].join("\n")
    end

    def precompiled_postamble(locals)
      [@outvar, super].join("\n")
    end

    # Erubis doesn't have ERB's line-off-by-one under 1.9 problem.
    # Override and adjust back.
    if RUBY_VERSION >= '1.9.0'
      def precompiled(locals)
        source, offset = super
        [source, offset - 1]
      end
    end
  end
end

Version data entries

187 entries across 148 versions & 24 rubygems

Version Path
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/brakeman-4.7.0/bundle/ruby/2.6.0/gems/tilt-2.0.10/lib/tilt/erubis.rb
brakeman-4.7.0 bundle/ruby/2.6.0/gems/tilt-2.0.10/lib/tilt/erubis.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/tilt-2.0.10/lib/tilt/erubis.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
tilt-2.0.10 lib/tilt/erubis.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/tilt-2.0.9/lib/tilt/erubis.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/tilt-2.0.9/lib/tilt/erubis.rb