class Es6::Template

Public Class Methods

default_mime_type() click to toggle source
# File lib/es6/template.rb, line 5
def self.default_mime_type
  'application/javascript'
end
engine_initialized?() click to toggle source
# File lib/es6/template.rb, line 9
def self.engine_initialized?
  true
end

Public Instance Methods

evaluate(context, locals, &block) click to toggle source
# File lib/es6/template.rb, line 23
def evaluate(context, locals, &block)
  logical_path = context.logical_path
  data = File.read(eval_file)

  result = Babel::Transpiler.transform(data, {
    'sourceMap' => context.es6_config.source_map,
    'sourceRoot' => source_root(logical_path),
    'filenameRelative' => filename_relative(logical_path)})

  # TODO: figure out who adding ; at the end of each js file
  result['code'] + "\n"
end
initialize_engine() click to toggle source
# File lib/es6/template.rb, line 13
def initialize_engine
end
prepare() click to toggle source
# File lib/es6/template.rb, line 16
def prepare
end
syntax() click to toggle source
# File lib/es6/template.rb, line 19
def syntax
  :es6
end

Private Instance Methods

filename_regexp() click to toggle source
# File lib/es6/template.rb, line 38
def filename_regexp
  /[^\/]*$/
end
filename_relative(logical_path) click to toggle source
# File lib/es6/template.rb, line 42
def filename_relative(logical_path)
  filename_regexp.match(logical_path)[0].to_s
end
source_root(logical_path) click to toggle source
# File lib/es6/template.rb, line 46
def source_root(logical_path)
  logical_path.gsub(filename_regexp, '')
end