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



940
941
942
943
944
945
946
# File 'lib/tina4/template.rb', line 940

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



934
935
936
937
938
# File 'lib/tina4/template.rb', line 934

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