Class: ProcessIt::JstProcessor

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/processit/processor/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.



17
18
19
# File 'lib/processit/processor/jst_processor.rb', line 17

def namespace
  @namespace
end

Class Method Details

.default_mime_typeObject



5
6
7
# File 'lib/processit/processor/jst_processor.rb', line 5

def self.default_mime_type
  'application/javascript'
end

.default_namespaceObject



9
10
11
# File 'lib/processit/processor/jst_processor.rb', line 9

def self.default_namespace
  'this.JST'
end

Instance Method Details

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



19
20
21
22
23
24
25
26
# File 'lib/processit/processor/jst_processor.rb', line 19

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

#prepareObject



13
14
15
# File 'lib/processit/processor/jst_processor.rb', line 13

def prepare
  @namespace = self.class.default_namespace
end