class Sprockets::CJS
Constants
- WRAPPER
Attributes
default_namespace[RW]
namespace[R]
Protected Instance Methods
evaluate(scope, locals, &block)
click to toggle source
# File lib/sprockets/cjs.rb, line 25 def evaluate(scope, locals, &block) if commonjs_module?(scope) scope.require_asset 'sprockets/cjs' WRAPPER % [ namespace, commonjs_module_name(scope), data ] else data end end
prepare()
click to toggle source
# File lib/sprockets/cjs.rb, line 21 def prepare @namespace = self.class.default_namespace end
Private Instance Methods
commonjs_module?(scope)
click to toggle source
# File lib/sprockets/cjs.rb, line 38 def commonjs_module?(scope) scope.pathname.to_s.include?('modules') end
commonjs_module_name(scope)
click to toggle source
# File lib/sprockets/cjs.rb, line 42 def commonjs_module_name(scope) scope.logical_path.to_s.gsub("modules/","") end