Skip to content

Instantly share code, notes, and snippets.

@nickserv
Created April 21, 2015 14:43
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