class Sprockets::CoffeeJsxScript

Preprocessor that runs CJSX source files through coffee-jsx-transform then compiles with coffee-script

Constants

CJSX_EXTENSION
CJSX_PRAGMA
COFFEE_CJSX_EXTENSION

Public Class Methods

call(input) click to toggle source
# File lib/sprockets/coffee-jsx-script.rb, line 21
def self.call(input)
  filename  = input[:source_path] || input[:filename]
  source    = input[:data]
  run(filename, source)
end
run(filename, source) click to toggle source
# File lib/sprockets/coffee-jsx-script.rb, line 27
def self.run(filename, source)
  if filename =~ COFFEE_CJSX_EXTENSION
    ::CoffeeReact.transform(source)
  elsif filename =~ CJSX_EXTENSION || source =~ CJSX_PRAGMA
    ::CoffeeScript.compile(::CoffeeReact.transform(source))
  else
    source
  end
end

Public Instance Methods

evaluate(scope, locals, &block) click to toggle source
# File lib/sprockets/coffee-jsx-script.rb, line 17
def evaluate(scope, locals, &block)
  self.class.run(scope.pathname.to_s, data)
end
prepare() click to toggle source
# File lib/sprockets/coffee-jsx-script.rb, line 14
def prepare
end