code: function automat(template, replacements/*...*/) {
      var hasReplacements = arguments.length > 1;
  
      // if `template` is a function, convert it to text
      if (typeof template === 'function') {
          template = template.call(this); // non-template function: call it with context and use return value
      }
  
      if (hasReplacements) {
          var args = arguments;
          template = template.replace(automat.replacersRegex, function(match, key) {
              key -= -1; // convert to number and increment
              return args.length > key ? args[key] : '';
          });
  
          template = template.replace(automat.encodersRegex, function(match, key) {
              key -= -1; // convert to number and increment
              if (args.length > key) {
                  var htmlEncoderNode = document.createElement('DIV');
                  htmlEncoderNode.textContent = args[key];
                  return htmlEncoderNode.innerHTML;
              } else {
                  return '';
              }
          });
      }
  
      return template;
  }
docs: single $ to replace 
  @summary String formatter.
  
  @desc String substitution is performed on numbered _replacer_ patterns like `${n}` or _encoder_ patterns like `%{n}` where n is the zero-based `arguments` index. So `${0}` would be replaced with the first argument following `text`.
  
  Encoders are just like replacers except the argument is HTML-encoded before being used.
  
  To change the format patterns, assign new `RegExp` patterns to `automat.encoders` and `automat.replacers`.
  
  @param {string|function} template - A template to be formatted as described above. Overloads:
  * A string primitive containing the template.
  * A function to be called with `this` as the calling context. The template is the value returned from this call.
  
  @param {...*} [replacements] - Replacement values for numbered format patterns.
  
  @return {string} The formatted text.
  
  @memberOf module:automat