require'simpledebugger.lua' function here( t, str, pat ) assert( type(t)=='table', 'expecting a table' ) assert( type(str)=='string', 'expecting a string' ) pat = pat or '$(%b<>)' local f = function(w) local m = t[strsub(w,2,-2)] or w -- stop"it" if type(m)=='function' then m = m(t) end return tostring(m) end return( gsub( str, pat, f ) ) end temp = [[ this is a $ for $ ]] local tab = { x = 'test', y = 'fun' } write( here( tab, temp ) ) write( here( temp, tab ) ) print"game over"