mochiscript 0.4.0.pre10 → 0.4.0.pre12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ require 'tilt'
2
+ require 'sprockets/engines'
3
+
4
+ module Mochiscript::Rails
5
+ class Engine < ::Rails::Engine
6
+ config.before_configuration {}
7
+ end
8
+
9
+ #
10
+ # Mochiscript template implementation. See:
11
+ # http://github.com/jeffsu/mochiscript
12
+ #
13
+ class MochiscriptTemplate < Tilt::Template
14
+ self.default_mime_type = 'application/javascript'
15
+
16
+ def prepare
17
+ @ctx = Mochiscript::Context.new
18
+ end
19
+
20
+ def evaluate(scope, locals, &block)
21
+ return @ctx.parse(data)
22
+ end
23
+ end
24
+ end
25
+
26
+ module Sprockets
27
+ register_engine '.ms', Mochiscript::Rails::MochiscriptTemplate
28
+ end