Class: Jade::Sprockets::Transformer
- Inherits:
-
Object
- Object
- Jade::Sprockets::Transformer
- Defined in:
- lib/jade-rails/sprockets/transformer.rb
Overview
Friendly with sprockets 2.x, 3.x, and 4.x. github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
Class Method Summary collapse
Instance Method Summary collapse
- #cache_key ⇒ Object
-
#initialize(filename) ⇒ Transformer
constructor
A new instance of Transformer.
- #render(context, _) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Transformer
Returns a new instance of Transformer.
20 21 22 23 |
# File 'lib/jade-rails/sprockets/transformer.rb', line 20 def initialize(filename) @filename = filename @source = yield end |
Class Method Details
.cache_key ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/jade-rails/sprockets/transformer.rb', line 46 def self.cache_key [name, PUG_RUBY_GEM_VERSION, PUG_RAILS_GEM_VERSION, Jade.compiler.version, Jade.compiler.class.name, Digest::SHA1.hexdigest(Jade.config.to_h.to_a.flatten.map(&:to_s).join(",")) ].join(":").freeze end |
.call(input) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/jade-rails/sprockets/transformer.rb', line 37 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 |
Instance Method Details
#cache_key ⇒ Object
29 30 31 |
# File 'lib/jade-rails/sprockets/transformer.rb', line 29 def cache_key self.class.cache_key end |
#render(context, _) ⇒ Object
25 26 27 |
# File 'lib/jade-rails/sprockets/transformer.rb', line 25 def render(context, _) self.class.run(@filename, @source, context) end |