def templatefile(filename, fillings) aFile = File.new(filename, "r") text = aFile.read() aFile.close() pattern = Regexp.new('%%(.*?)%%') text.gsub!(pattern) { fillings[$1] || "" } text end fields = { 'username' => whats_his_name, 'count' => login_count, 'total' => minutes_used } puts templatefile('simple.template', fields) # @@INCOMPLETE@@ # An example using databases is missing |