How can I store a format string like this
s = "test with #{value}"
so that later on I can do this
puts s % {:value => 'hello'}
If I write the first thing, it complains that value is not found (true, I want to provide it later). If I use the raw string s = 'test with #{value}' it is not interpolated.
I specifically tried this:
@format_html = "<a href=\"http://boardgamegeek.com/user/%{who.sub ' ', '+'}\">%{who}</a> receives <a href=\"%{got[0]}\">%{got[1]}</a> from <a href=\"http://boardgamegeek.com/user/%{from.sub ' ', '+'}\">%{from}</a> and sends <a href=\"%{given[0]}\">%{given[1]}</a> to <a href=\"http://boardgamegeek.com/user/%{to.sub ' ', '+'}\">%{to}</a>"
puts @format_html % {:who => 'who',
:given => 'given',
:from => 'from',
:got => 'got',
:to => 'to'}
and I get this:
KeyError (key{who.sub ' ', '+'} not found):
This works only with ruby 1.9+: