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 40 41 42 43 44 45 46 |
# 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 ns_name = "#{ns}," ns_ref = "(window.Lanes ? window.Lanes['#{ns}'] : null)," ns_file_ref = "window.Lanes['#{ns}']" else ns_name = "" ns_ref = "" ns_file_ref = "window.Lanes" end file="{namespace:#{ns_file_ref},extensionName:'#{ns}',path:#{path}}" "(function(Lanes,#{ns_name}_,LC,React,BS,FILE,window,undefined)"\ "{\n#{js}\n})"\ "(window.Lanes,#{ns_ref}window.Lanes.Vendor.ld,"\ "window.Lanes.Components,"\ "window.Lanes.Vendor.React,"\ "window.Lanes.Vendor.ReactBootstrap,"\ "#{file}, window);" end |