→ Erb Eval
21 May 2008
Because I always forget how to do it:
require 'erb'
name = 'bob'
template = 'whatever, <%= name %>'
puts ERB.new(template).result(binding)
Useful for sticking Ruby into config files:
config = YAML.load(ERB.new(IO.read(config_file)).result)