Sha256: f39cfb2ba477b785b57756eb605a9f4a8260474e909ea569b7586134b00fbfda

Contents?: true

Size: 760 Bytes

Versions: 6

Compression:

Stored size: 760 Bytes

Contents

require 'tilt'
require 'sprockets'
require 'opal/sprockets/processor'

module Opal
  module ERB
    class Processor < ::Opal::Processor
      def initialize_engine
        super
        require_template_library 'opal/erb'
      end

      def evaluate(context, locals, &block)
        compiler = Opal::ERB::Compiler.new(@data, context.logical_path.sub(/#{REGEXP_START}templates\//, ''))
        @data = compiler.prepared_source
        super
      end
    end
  end
end

Tilt.register 'opalerb', Opal::ERB::Processor

if Sprockets.respond_to? :register_transformer
  Sprockets.register_engine '.opalerb', Opal::ERB::Processor, mime_type: 'application/javascript', silence_deprecation: true
else
  Sprockets.register_engine '.opalerb', Opal::ERB::Processor
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-0.10.6 lib/opal/sprockets/erb.rb
opal-0.10.6.beta lib/opal/sprockets/erb.rb
opal-0.10.5 lib/opal/sprockets/erb.rb
opal-0.10.4 lib/opal/sprockets/erb.rb
opal-0.10.3 lib/opal/sprockets/erb.rb
opal-0.10.2 lib/opal/sprockets/erb.rb