class Tilt::ES6ModuleTranspilerTemplate
Constants
- Node
Public Instance Methods
evaluate(scope, locals, &block)
click to toggle source
# File lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb, line 19 def evaluate(scope, locals, &block) @output ||= Node.exec(generate_source(scope)) end
prepare()
click to toggle source
# File lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb, line 14 def prepare # intentionally left empty # Tilt requires this method to be defined end
Private Instance Methods
compiler_method()
click to toggle source
# File lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb, line 53 def compiler_method type = { amd: 'AMD', cjs: 'CJS', globals: 'Globals' }[ES6ModuleTranspiler.compile_to.to_sym] "to#{type}" end
compiler_options()
click to toggle source
# File lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb, line 63 def compiler_options ::JSON.generate(ES6ModuleTranspiler.compiler_options, quirks_mode: true) end
generate_source(scope)
click to toggle source
# File lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb, line 29 def generate_source(scope) <<-SOURCE var Compiler, compiler, output; Compiler = require("#{transpiler_path}").Compiler; compiler = new Compiler(#{::JSON.generate(data, quirks_mode: true)}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}); return output = compiler.#{compiler_method}(); SOURCE end
module_name(root_path, logical_path)
click to toggle source
# File lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb, line 38 def module_name(root_path, logical_path) path = '' if prefix = ES6ModuleTranspiler.lookup_prefix(File.join(root_path, logical_path)) path = File.join(prefix, logical_path) else path = logical_path end if ES6ModuleTranspiler.transform path = ES6ModuleTranspiler.transform.call(path) end path end
transpiler_path()
click to toggle source
# File lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb, line 25 def transpiler_path File.expand_path('../../support/es6-module-transpiler.js', __FILE__) end