Kuang Dong wrote: > File 1: test.tpl > > Hello,#{name}! > > File 2: test.rb > > name = "jack" > f = File.open("test.tpl") > puts f.read > puts "Hello,#{name}" > f.close > > And the result is: > Hello,#{name}! > Hello,jack! > > How to change the "#{name}" to "jack"? > > Use ERB to do templating! File 1: test.tpl Hello, <%= name %>! File 2: test.rb require 'erb' name = "Jack" File.open('test.tpl') { |file| puts ERB.new(file.read).result } Bye. Andrea