Class: Lanes::API::JsAssetCompiler
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Lanes::API::JsAssetCompiler
- Defined in:
- lib/lanes/api/javascript_processor.rb
Direct Known Subclasses
Class Method Summary collapse
-
.register(env) ⇒ Object
NOOP.
Instance Method Summary collapse
Class Method Details
.register(env) ⇒ Object
NOOP
15 16 17 18 19 20 |
# File 'lib/lanes/api/javascript_processor.rb', line 15 def self.register(env) self.descendants.each do | klass | klass.default_mime_type = 'application/javascript' env.register_engine( klass.registered_extension, klass ) end end |
Instance Method Details
#prepare ⇒ Object
12 13 14 |
# File 'lib/lanes/api/javascript_processor.rb', line 12 def prepare # NOOP end |
#wrap_js(scope, js) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lanes/api/javascript_processor.rb', line 22 def wrap_js(scope, js) dirs = scope.logical_path.split(File::SEPARATOR) ns = dirs.many? ? dirs.first.camelize : nil path = "[" + dirs.map{|d| "\"#{d}\"" }.join(",") + "]" # if the file is being loaded under the "lanes" directory # it's not an extension if ns && ns != "Lanes" ns = ns.underscore.camelize ref = "(window.Lanes ? window.Lanes['#{ns}'] : null)" "(function(Lanes, #{ns}, _, window, FILE, undefined)"\ "{\n#{js}\n})(window.Lanes,#{ref},window._, window,"\ "{namespace:#{ref},extensionName:'#{ns}',path:#{path}});" else "(function(Lanes, _, window, FILE, undefined)"\ "{\n#{js}\n})(window.Lanes,window._, window,"\ "{namespace:window.Lanes,extensionName:'Lanes',path:#{path}});" end end |