Class: HangingGardens::ModuleWrapper
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- HangingGardens::ModuleWrapper
- Defined in:
- lib/hanging_gardens/module_wrapper.rb
Constant Summary collapse
- RE_REQUIRE =
/(?:\s+|(?:[=]\s*)|(?:^\s*))require\s*\((.+)\)/
- SANDBOX =
%w( module exports require window document console screen history location navigartor __filename __dirname setInterval setTimeout clearInterval clearTimeout )
Instance Method Summary collapse
Instance Method Details
#evaluate(context, locals, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hanging_gardens/module_wrapper.rb', line 28 def evaluate(context, locals, &block) context.require_asset 'hanging_gardens/runtime.js' unless context.logical_path == 'browser/console' or context.logical_path == 'browser/window' context.require_asset 'browser/console' end data.scan(RE_REQUIRE) do |m| path = YAML.load(m.first) if path[0,2] == './' or path[0,3] == '../' path = File.join(File.dirname(context.logical_path), path) end context.require_asset path end "HG.register(#{context.logical_path.inspect}, function(#{SANDBOX.join(', ')}){\n#{data}\n});\n" end |
#prepare ⇒ Object
25 26 |
# File 'lib/hanging_gardens/module_wrapper.rb', line 25 def prepare end |