Class: HamlCoffeeAssets::Transformer
- Inherits:
-
Object
- Object
- HamlCoffeeAssets::Transformer
- Defined in:
- lib/haml_coffee_assets/transformer.rb
Overview
Haml Coffee Sprockets processor
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename, &block) ⇒ Transformer
constructor
A new instance of Transformer.
- #render(context, empty_hash_wtf) ⇒ Object
Constructor Details
#initialize(filename, &block) ⇒ Transformer
Returns a new instance of Transformer.
7 8 9 10 |
# File 'lib/haml_coffee_assets/transformer.rb', line 7 def initialize(filename, &block) @filename = filename @source = block.call end |
Class Method Details
.call(input) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/haml_coffee_assets/transformer.rb', line 23 def self.call(input) filename = input[:filename] name = input[:name] source = input[:data] context = input[:environment].context_class.new(input) result = run(filename, name, source, context) context..merge(data: result) end |
.run(filename, name, source, context) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/haml_coffee_assets/transformer.rb', line 16 def self.run(filename, name, source, context) jst = !!(filename =~ /\.jst\.hamlc(?:\.|$)/) name = HamlCoffeeAssets.config.name_filter.call(name) if HamlCoffeeAssets.config.name_filter && !jst HamlCoffeeAssets::Compiler.compile(name, source, !jst) end |
Instance Method Details
#render(context, empty_hash_wtf) ⇒ Object
12 13 14 |
# File 'lib/haml_coffee_assets/transformer.rb', line 12 def render(context, empty_hash_wtf) self.class.run(@filename, @filename, @source, context) end |