Skip to content

Instantly share code, notes, and snippets.

@briandonahue
Created October 22, 2009 13:33
Show Gist options
  • Save briandonahue/215946 to your computer and use it in GitHub Desktop.
Save briandonahue/215946 to your computer and use it in GitHub Desktop.
def expand_template( template_file, output_file)
puts "Building #{output_file}"
template = File.open(template_file, "r")
output = File.open(output_file, "w")
template.each_line do |template_line|
template_line.gsub(/@([^@]+)@/) do |token|
value = @config[$1.downcase]
unless value.nil?
template_line = template_line.gsub(token, value.to_s)
end
end
output.write(template_line)
end
template.close
output.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment