I'm sure this is not the most efficient or most all-encompassing way to do it 
but it's one of the simplest:
    
    
    import sequtils, strutils, tables
    
    proc `%` (s: string, subs: openArray[(string, string)]): string =
      var newSubs = newSeqOfCap[string](subs.len * 2)
      for sub in subs:
        newSubs.add(sub[0])
        newSubs.add(sub[1])
      result = format(s, newSubs)
    
    echo "$foo, $baa" % {"foo": "foofoo", "baa": "baabaa"}
    
    
    Run

You can also do `"$foo $bar" % ["foo", "foofoo", "bar", "barbar"]` today. 
Handling the table syntax would be neat though, even if we have `strformat`, 
since that's compile time only.

Reply via email to