Class: HamlCoffeeTemplate::Processor
- Inherits:
-
Object
- Object
- HamlCoffeeTemplate::Processor
- Defined in:
- lib/haml_coffee_template/processor.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename, &block) ⇒ Processor
constructor
A new instance of Processor.
- #render(context, _empty_hash_wtf) ⇒ Object
Constructor Details
#initialize(filename, &block) ⇒ Processor
Returns a new instance of Processor.
3 4 5 6 |
# File 'lib/haml_coffee_template/processor.rb', line 3 def initialize(filename, &block) @filename = filename @source = block.call end |
Class Method Details
.call(input) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/haml_coffee_template/processor.rb', line 19 def self.call(input) filename = input[:filename] source = input[:data] context = input[:environment].context_class.new(input) result = run(filename, source, context) context..merge(data: result) end |
.compiler ⇒ Object
27 28 29 |
# File 'lib/haml_coffee_template/processor.rb', line 27 def self.compiler @compiler ||= Compiler.new end |
.run(filename, source, context) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/haml_coffee_template/processor.rb', line 12 def self.run(filename, source, context) compiler.template(context.logical_path, source) rescue StandardError => e STDOUT.puts("(#{name}) Failed to compile: #{filename}") raise e end |
Instance Method Details
#render(context, _empty_hash_wtf) ⇒ Object
8 9 10 |
# File 'lib/haml_coffee_template/processor.rb', line 8 def render(context, _empty_hash_wtf) self.class.run(@filename, @source, context) end |