code: def format(self, template=None):
          
          pattern = r"(?:<([^<]*?)\$(\w+)([^>]*?)>)"
          s = sub(pattern, self._format_repl, template or self.template)
          s = self._str_fix_whitespace(s)
          return s
docs: Substitutes variables within template with that of fields'