Class: Sprockets::CoffeeReactScript
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Sprockets::CoffeeReactScript
- Defined in:
- lib/sprockets/coffee-react-script.rb
Overview
Preprocessor that runs CJSX source files through coffee-react-transform then compiles with coffee-script
Constant Summary collapse
- CJSX_EXTENSION =
/\.cjsx[^\/]*?$/- CJSX_PRAGMA =
/^\s*#[ \t]*@cjsx/i
Instance Method Summary collapse
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/sprockets/coffee-react-script.rb', line 16 def evaluate(scope, locals, &block) if scope.pathname.to_s =~ /\.coffee\.cjsx/ ::CoffeeReact.transform(data) elsif scope.pathname.to_s =~ CJSX_EXTENSION || data =~ CJSX_PRAGMA ::CoffeeScript.compile(::CoffeeReact.transform(data)) else data end end |
#prepare ⇒ Object
13 14 |
# File 'lib/sprockets/coffee-react-script.rb', line 13 def prepare end |