Class: Sprockets::JstProcessor

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/sprockets/jst_processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace


15
16
17
# File 'lib/sprockets/jst_processor.rb', line 15

def namespace
  @namespace
end

Class Method Details

.default_namespaceObject


7
8
9
# File 'lib/sprockets/jst_processor.rb', line 7

def self.default_namespace
  'this.JST'
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object


17
18
19
20
21
22
# File 'lib/sprockets/jst_processor.rb', line 17

def evaluate(scope, locals, &block)
  <<-JST
(function() { #{namespace} || (#{namespace} = {}); #{namespace}[#{scope.logical_path.inspect}] = #{indent(data)};
}).call(this);
  JST
end

#prepareObject


11
12
13
# File 'lib/sprockets/jst_processor.rb', line 11

def prepare
  @namespace = self.class.default_namespace
end