Class: Sprockets::Processor

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

Overview

‘Processor` creates an anonymous processor class from a block.

register_preprocessor :my_processor do |context, data|
  # ...
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nameObject



16
17
18
# File 'lib/sprockets/processor.rb', line 16

def self.name
  "Sprockets::Processor (#{@name})"
end

.processorObject

‘processor` is a lambda or block



12
13
14
# File 'lib/sprockets/processor.rb', line 12

def self.processor
  @processor
end

.to_sObject



20
21
22
# File 'lib/sprockets/processor.rb', line 20

def self.to_s
  name
end

Instance Method Details

#evaluate(context, locals) ⇒ Object

Call processor block with ‘context` and `data`.



28
29
30
# File 'lib/sprockets/processor.rb', line 28

def evaluate(context, locals)
  self.class.processor.call(context, data)
end

#prepareObject



24
25
# File 'lib/sprockets/processor.rb', line 24

def prepare
end