My aim is to replace keys in a string with values in hash. I am doing it like this:
"hello %{name}, today is %{day}" % {name: "Tim", day: "Monday"}
If a key in the string in missing in the hash:
"hello %{name}, today is %{day}" % {name: "Tim", city: "Lahore"}
then it will throw an error.
KeyError: key{day} not found
Expected result should be:
"hello Tim, today is %{day}" or "hello Tim, today is "
Can someone guide me in a direction to replace only the matching keys without throwing any errors?