Sha256: da9ef1d52a3cbcac79d1d2deed881598e225db52c25f7951c29cf8f3b565d8e3

Contents?: true

Size: 777 Bytes

Versions: 3

Compression:

Stored size: 777 Bytes

Contents

require 'opal'
require 'tilt'
require 'opal/erb'
require 'sprockets'

module Opal
  module ERB
    class Processor < Tilt::Template
      # vvv BOILERPLATE vvv
      self.default_mime_type = 'application/javascript'

      def self.engine_initialized?
        true
      end

      def self.version
        ::Opal::VERSION
      end

      def initialize_engine
        require_template_library 'opal'
      end

      def prepare
      end
      # ^^^ BOILERPLATE ^^^


      def evaluate(context, locals, &block)
        context.require_asset 'erb'
        Opal::ERB.compile data, context.logical_path.sub(/^templates\//, '')
      end
    end
  end
end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opal-0.6.3 lib/opal/sprockets/erb.rb
opal-0.6.2 lib/opal/sprockets/erb.rb
opal-0.6.1 lib/opal/sprockets/erb.rb