I have an ERB template inlined into Ruby code:
require \'erb\' DATA = { :a => \"HELLO\", :b => \"WORLD\", } template = ERB.new <<-EOF
Simple solution using Binding:
b = binding b.local_variable_set(:a, 'a') b.local_variable_set(:b, 'b') ERB.new(template).result(b)