Skip to content

Instantly share code, notes, and snippets.

@nalabjp
Created November 23, 2018 09:27
Show Gist options
  • Save nalabjp/2825c65fb28602e5f07322e334380e36 to your computer and use it in GitHub Desktop.
Save nalabjp/2825c65fb28602e5f07322e334380e36 to your computer and use it in GitHub Desktop.
String Interpolation in YAML
require 'yaml'
ENV.update('foo' => 'FOO')
ENV.update('bar' => 'BAR')
ENV.update('baz' => 'BAZ')
p YAML.load(<<EOS)
---
foo: !ruby/string #{ENV['foo']}
bar: !str #{ENV['bar']}
baz: ! #{ENV['baz']}
EOS
# => {"foo"=>"FOO", "bar"=>"BAR", "baz"=>"BAZ"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment