Sha256: 19d5b415502266fae19ae7e6a31957be580e2f1001f9169731b9559cb59b7aff
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
require "sprockets" require "sprockets/traceur/version" require "traceur-rb" module Sprockets module Traceur class Template < Tilt::Template self.default_mime_type = 'application/javascript' def self.engine_initialized? true end def initialize_engine end def prepare end def evaluate(scope, locals, &block) name = module_name(scope) if ::Rails.present? filename = file.gsub(/^#{::Rails.root}/, '') end ::Traceur.compile(data, module_name: name, filename: filename) end private def module_name(scope) asset_paths = scope.environment.paths asset_paths.each do |path| if file.start_with?(path) return basename(file.gsub(path, '')) end end basename(file) end def basename(file) file.gsub(/\.[^\/]+$/, '').gsub(/^\//, '') end end end register_engine '.next', Traceur::Template register_engine '.es6', Traceur::Template append_path ::Traceur.assets_path end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sprockets-traceur-0.0.4 | lib/sprockets/traceur.rb |
sprockets-traceur-0.0.3 | lib/sprockets/traceur.rb |