Class: Condenser::Erubi

Inherits:
Object
  • Object
show all
Defined in:
lib/condenser/templating_engine/erb.rb

Class Method Summary collapse

Class Method Details

.call(environment, data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/condenser/templating_engine/erb.rb', line 7

def self.call(environment, data)
  source = ::Erubi::Engine.new(data[:source], {
    preamble:   "@output_buffer = String.new;",
    bufvar:     "@output_buffer",
    postamble:  "@output_buffer.to_s"
  }).src
  
  source = eval("proc { #{source} }", nil, data[:filename] || "(erubi)")
  source = environment.new_context_class.instance_eval(&source)

  data[:source] = source
end

.setup(environment) ⇒ Object



3
4
5
# File 'lib/condenser/templating_engine/erb.rb', line 3

def self.setup(environment)
  require "erubi" unless defined?(::Erubi::Engine)
end