Ruby strings with embedded variables

ruby, yaml

Solution

str = "Hi %{name}, %{msg}. Bye %{name}." #yaml it, de-yaml it back to string
h = {:name=> "John", :msg=> "this message is for you"}
puts str % h
#=>Hi John, This message is for you. Bye John.

Problem

How can I store ruby string with embedded variables in yaml, but insert variable values only when I get string from yaml?

Original source

Related problems