Skip to content

Instantly share code, notes, and snippets.

@nickmccurdy
Created April 21, 2015 14:43
Show Gist options
  • Save nickmccurdy/9ecdee6353aed2db5831 to your computer and use it in GitHub Desktop.
Save nickmccurdy/9ecdee6353aed2db5831 to your computer and use it in GitHub Desktop.
Using ERB with a YAML config file in Ruby
:uri: http://example.com/?host=<%= hostname %>
require 'erb'
require 'yaml'
hostname = 'example.com'
template = ERB.new File.read 'config.yml.erb'
result = YAML.load template.result binding
puts result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment