Skip to content

Instantly share code, notes, and snippets.

@yasugahira0810
Last active March 14, 2016 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasugahira0810/38d21cc1faf51a098c6c to your computer and use it in GitHub Desktop.
Save yasugahira0810/38d21cc1faf51a098c6c to your computer and use it in GitHub Desktop.
require 'erb'
require 'yaml'
# VARIABLE DEFINITION
var1 = 'bbb'
var2 = 'ddd'
# FORMAT TRANSLATION
yml_erb = ARGF.read()
ruby_data_type = ERB.new(yml_erb).result(binding)
yml = YAML.load(ruby_data_type)
puts yml.to_yaml()
# ONE LINER
# ruby -r erb -r yaml -e "var1 = 'bbb'; var2 = 'ddd'; puts YAML.load(ERB.new(File.open('test.yml.erb').read).result(binding)).to_yaml()"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment