Sha256: ff38ce9f17083d91b82d5b83ab63ec968d0e88361359f01ced3b2bcd62373ba1

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

require 'haml'
require 'opal-sprockets'

module Opal
  module Haml
    OPAL_SPROCKETS_PROCESSOR = defined?(Opal::Processor) ?
      ::Opal::Processor :
      ::Opal::Sprockets::Processor

    class Processor < OPAL_SPROCKETS_PROCESSOR
      self.default_mime_type = 'application/javascript'

      def evaluate(context, locals, &block)
        @data = Opal::Haml.compile_haml @data, context.logical_path.sub(/^templates\//, '')
        super
      end

      def self.compiler_options
        # otherwise would check current class `attr_accessor`s
        OPAL_SPROCKETS_PROCESSOR.compiler_options
      end
    end
  end
end

if Sprockets.respond_to? :register_transformer
  extra_args = [{mime_type: 'application/javascript', silence_deprecation: true}]
else
  extra_args = []
end

Sprockets.register_engine '.haml', Opal::Haml::Processor, *extra_args

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-haml-0.4.6 lib/opal/haml/processor.rb
opal-haml-0.4.5 lib/opal/haml/processor.rb