docs: def format_string(string, context):
      """String-template format a string:
  
      >>> format_string('$foo and ${foo}s', dict(foo=42))
      '42 and 42s'
  
      This does not do any attribute lookup etc.  For more advanced string
      formattings have a look at the `werkzeug.template` module.
  
      :param string: the format string.
      :param context: a dict with the variables to insert.
      """
  
      def lookup_arg(match):
          x = context[match.group(1) or match.group(2)]
          if not isinstance(x, string_types):
              x = type(string)(x)
          return x
  
      return _format_re.sub(lookup_arg, string)