Mega Code Archive

 
Categories / Ruby / String
 

Use ERB to replace string

require 'erb' template = ERB.new %q{static string <%= food %>!} food = "bacon" template.result(binding)            food = "peanut butter" template.result(binding)            puts template.result