module CoffeeScript

Constants

CompilationError
EngineError
Error

Public Instance Methods

compile(script, options = {}) click to toggle source

Compile a script (String or IO) to JavaScript.

# File lib/coffee_script.rb, line 48
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

  wrapper = <<-WRAPPER
    (function(script, options) {
      try {
        return CoffeeScript.compile(script, options);
      } catch (err) {
        if (err instanceof SyntaxError && err.location) {
          throw new SyntaxError([
            err.filename || "[stdin]",
            err.location.first_line + 1,
            err.location.first_column + 1
          ].join(":") + ": " + err.message)
        } else {
          throw err;
        }
      }
    })
  WRAPPER

  Source.context.call(wrapper, script, options)
end
engine() click to toggle source
# File lib/coffee_script.rb, line 37
def engine
end
engine=(engine) click to toggle source
# File lib/coffee_script.rb, line 40
def engine=(engine)
end
version() click to toggle source
# File lib/coffee_script.rb, line 43
def version
  Source.version
end