Created
April 21, 2015 14:43
-
-
Save nickserv/9ecdee6353aed2db5831 to your computer and use it in GitHub Desktop.
Using ERB with a YAML config file in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:uri: http://example.com/?host=<%= hostname %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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