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



469
470
471
472
473
474
475
# File 'lib/tina4/template.rb', line 469

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



463
464
465
466
467
# File 'lib/tina4/template.rb', line 463

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