Class: Jade::SprocketsTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/jade-rails/template.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, &block) ⇒ SprocketsTransformer

Returns a new instance of SprocketsTransformer.



6
7
8
9
# File 'lib/jade-rails/template.rb', line 6

def initialize(filename, &block)
  @filename = filename
  @source   = block.call
end

Class Method Details

.call(input) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/jade-rails/template.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

.run(filename, source, context) ⇒ Object



15
16
17
# File 'lib/jade-rails/template.rb', line 15

def self.run(filename, source, context)
  Jade.compile(source, filename: filename, client: true)
end

Instance Method Details

#render(context, empty_hash_wtf) ⇒ Object



11
12
13
# File 'lib/jade-rails/template.rb', line 11

def render(context, empty_hash_wtf)
  self.class.run(@filename, @source, context)
end