Class: Tina4::Template::ErbEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/tina4/template.rb

Class Method Summary collapse

Class Method Details

.create_binding(context) ⇒ Object



885
886
887
888
889
890
891
# File 'lib/tina4/template.rb', line 885

def self.create_binding(context)
  b = binding
  context.each do |key, value|
    b.local_variable_set(key.to_sym, value)
  end
  b
end

.render(content, context) ⇒ Object



879
880
881
882
883
# File 'lib/tina4/template.rb', line 879

def self.render(content, context)
  require "erb"
  binding_obj = create_binding(context)
  ERB.new(content, trim_mode: "-").result(binding_obj)
end