Module: EmberScript

Defined in:
lib/ember_script.rb,
lib/ember_script/version.rb

Defined Under Namespace

Modules: Source Classes: EmberScriptTemplate

Constant Summary collapse

VERSION =
"0.0.5"

Class Method Summary collapse

Class Method Details

.compile(script, options = {}) ⇒ Object

Compile an EmberScript file to JavaScript or generate the source maps.

Parameters:

  • the (String, #read)

    source string or IO

  • options (Hash) (defaults to: {})

    the compiler options

Options Hash (options):

  • bare (Boolean)

    compile the JavaScript without the top-level function safety wrapper

  • format (String)

    the output format, either ‘:map` or `:js`



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ember_script.rb', line 38

def compile(script, options = {})
  script = script.read if script.respond_to?(:read)

  if options.key?(:bare)
  elsif options.key?(:no_wrap)
    options[:bare] = options[:no_wrap]
  else
    options[:bare] = false
  end
  bare = options[:bare] ? "--bare" : ""

  Source.context.call("function() { return EmberScript.em2js.apply(EmberScript, arguments); }", script, options)
end