Class: Tilt::ES6ModuleTranspilerTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



4
5
6
# File 'lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb', line 4

def node
  @node
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



15
16
17
# File 'lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb', line 15

def evaluate(scope, locals, &block)
  @output ||= @node.exec(generate_source(scope))
end

#prepareObject



6
7
8
9
10
11
12
13
# File 'lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb', line 6

def prepare
  @node = ::ExecJS::ExternalRuntime.new(
    name: 'Node.js (V8)',
    command: ['nodejs', 'node'],
    runner_path: File.expand_path('../../support/es6_node_runner.js', __FILE__),
    encoding: 'UTF-8'
  )
end