class Pug::Sprockets::Transformer
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
Public Class Methods
cache_key()
click to toggle source
# File lib/pug-rails/sprockets/transformer.rb, line 46 def self.cache_key [name, PUG_RUBY_GEM_VERSION, PUG_RAILS_GEM_VERSION, Pug.compiler.version, Pug.compiler.class.name, Digest::SHA1.hexdigest(Pug.config.to_h.to_a.flatten.map(&:to_s).join(",")) ].join(":").freeze end
call(input)
click to toggle source
# File lib/pug-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.metadata.merge(data: result) end
new(filename) { || ... }
click to toggle source
# File lib/pug-rails/sprockets/transformer.rb, line 20 def initialize(filename) @filename = filename @source = yield end
run(filename, source, context)
click to toggle source
# File lib/pug-rails/sprockets/transformer.rb, line 33 def self.run(filename, source, context) Pug::Sprockets.compile(source, filename: filename, client: true) end
Public Instance Methods
cache_key()
click to toggle source
# File lib/pug-rails/sprockets/transformer.rb, line 29 def cache_key self.class.cache_key end
render(context, _)
click to toggle source
# File lib/pug-rails/sprockets/transformer.rb, line 25 def render(context, _) self.class.run(@filename, @source, context) end